Skip to content

Commit

Permalink
sketch out key part for cip126
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryun1 committed Sep 22, 2024
1 parent d6ea954 commit ceae15f
Show file tree
Hide file tree
Showing 5 changed files with 476 additions and 4 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@ Further, we show how these keys can be used to create addresses and DRep IDs.

WIP

### [CIP-105 Conway Era Keys](./examples/CIP-105/cip-105-test-vectors.js)
### [CIP-105 Conway Era Keys - Test Vectors](./examples/CIP-105/cip-105-test-vectors.js)

In this example we make extensive test vectors for [CIP-105](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0105).
In this example we make test vectors for [CIP-105](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0105).

### [CIP-136 CC Vote Rationale - Test Vectors](./examples/CIP-136/cip-136-test-vectors.js)

In this example we make test vectors for [CIP-136](https://github.com/cardano-foundation/CIPs/tree/master/CIP-0136).

## To run examples

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Buffer } from 'buffer';
import {Jsonld} from 'jsonld';
import {
PrivateKey,
Credential,
Expand All @@ -10,6 +11,8 @@ const privateKeyHex = '105d2ef2192150655a926bca9cccf5e2f6e496efa9580508192e1f4a7
const messageToSignHex = '';
const networkTag = 1; // 1 for mainnet, 0 for testnet

const pathToMetadataDocument = './cip-136-test-vectors.jsonld';

// ########### Keys ###########

// Create public key from private key
Expand All @@ -20,6 +23,22 @@ const publicKey = privateKey.to_public();
const credential = Credential.from_keyhash(publicKey.hash());
const address = (EnterpriseAddress.new(networkTag, credential)).to_address();

// ########### JSONLD ###########

const doc = {
"http://schema.org/name": "Manu Sporny",
"http://schema.org/url": {"@id": "http://manu.sporny.org/"},
"http://schema.org/image": {"@id": "http://manu.sporny.org/images/manu.png"}
};

const context = {
"name": "http://schema.org/name",
"homepage": {"@id": "http://schema.org/url", "@type": "@id"},
"image": {"@id": "http://schema.org/image", "@type": "@id"}
};

const nquads = await jsonld.toRDF(doc, {format: 'application/n-quads'});

// ########### Signing ###########

const signature = privateKey.sign(Buffer.from(messageToSignHex, 'hex'));
Expand Down
92 changes: 92 additions & 0 deletions examples/CIP-136/treasury-withdrawal-unconstitutional.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
{
"@context": {
"@language": "en-us",
"CIP100": "https://github.com/cardano-foundation/CIPs/blob/master/CIP-0100/README.md#",
"CIP136": "https://github.com/cardano-foundation/CIPs/blob/master/CIP-0136/README.md#",
"hashAlgorithm": "CIP100:hashAlgorithm",
"body": {
"@id": "CIP136:body",
"@context": {
"references": {
"@id": "CIP100:references",
"@container": "@set",
"@context": {
"GovernanceMetadata": "CIP100:GovernanceMetadataReference",
"Other": "CIP100:OtherReference",
"label": "CIP100:reference-label",
"uri": "CIP100:reference-uri",
"RelevantArticles": "CIP136:RelevantArticles"
}
},
"summary": "CIP136:summary",
"rationaleStatement": "CIP136:rationaleStatement",
"precedentDiscussion": "CIP136:precedentDiscussion",
"counterargumentDiscussion": "CIP136:counterargumentDiscussion",
"conclusion": "CIP136:conclusion",
"internalVote": {
"@id": "CIP136:internalVote",
"@container": "@set",
"@context": {
"constitutional": "CIP136:constitutional",
"unconstitutional": "CIP136:unconstitutional",
"abstain": "CIP136:abstain",
"didNotVote": "CIP136:didNotVote"
}
}
}
},
"authors": {
"@id": "CIP100:authors",
"@container": "@set",
"@context": {
"did": "@id",
"name": "http://xmlns.com/foaf/0.1/name",
"witness": {
"@id": "CIP100:witness",
"@context": {
"witnessAlgorithm": "CIP100:witnessAlgorithm",
"publicKey": "CIP100:publicKey",
"signature": "CIP100:signature"
}
}
}
}
},
"hashAlgorithm": "blake2b-256",
"body": {
"summary": "Ryan using treasury funds to buy an island is unconstitutional.",
"rationaleStatement": "The Cardano treasury is not meant to be used for personal gain, it should be for the benefit of the community.",
"precedentDiscussion": "No precedent",
"counterargumentDiscussion": "It would be pretty cool.",
"conclusion": "In conclusion spending the treasury to benefit a single dude, bad.",
"internalVote": {
"constitutional": 1,
"unconstitutional": 0,
"abstain": 0,
"didNotVote": 0
},
"references": [
{
"@type": "relevantArticles",
"label": "Article III section 8.",
"uri": "https://github.com/IntersectMBO/interim-constitution/blob/main/cardano-constitution-0.txt#L231"
},
{
"@type": "Other",
"label": "A cool island for Ryan",
"uri": "https://www.google.com/maps/place/World's+only+5th+order+recursive+island/@62.6511465,-97.7946829,15.75z/data=!4m14!1m7!3m6!1s0x5216a167810cee39:0x11431abdfe4c7421!2sWorld's+only+5th+order+recursive+island!8m2!3d62.651114!4d-97.7872244!16s%2Fg%2F11spwk2b6n!3m5!1s0x5216a167810cee39:0x11431abdfe4c7421!8m2!3d62.651114!4d-97.7872244!16s%2Fg%2F11spwk2b6n?authuser=0&entry=ttu"
}
]
},
"authors": [
{
"name": "Ryan Williams",
"witness": {
"witnessAlgorithm": "ed25519",
"publicKey": "7ea09a34aebb13c9841c71397b1cabfec5ddf950405293dee496cac2f437480a",
"signature": "a476985b4cc0d457f247797611799a6f6a80fc8cb7ec9dcb5a8223888d0618e30de165f3d869c4a0d9107d8a5b612ad7c5e42441907f5b91796f0d7187d64a01"
}
}
]
}

Loading

0 comments on commit ceae15f

Please sign in to comment.