11; This c509 Certificate format is based upon:
2- ; https://datatracker.ietf.org/doc/draft-ietf-cose-cbor-encoded-cert/09 /
2+ ; https://datatracker.ietf.org/doc/draft-ietf-cose-cbor-encoded-cert/11 /
33; And is restricted/customized to better enable compatibility with Plutus scripts
4- ; that would consume them, without loosing necessary features of x509
4+ ; that would consume them, without losing necessary features of x509
55; Not all x509 features are supported and some fields have different semantics to improve
66; certificate size and ability to be processed by Plutus Scripts.
77
8- ; cspell: words reencoded, biguint
8+ ; cspell: words reencoded, biguint, stake1uyehkck0lajq8gr28t9uxnuvgcqrc6070x3k9r8048z8y5gh6ffgw
99
10- C509CertificatePlutusRestrictedSubset = [ TBSCertificate, issuerSignatureValue: ed25519Signature, ]
10+ C509CertificatePlutusRestrictedSubset = [
11+ TBSCertificate,
12+ issuerSignatureValue: ed25519Signature
13+ ]
1114
1215; The elements of the following group are used in a CBOR Sequence:
1316TBSCertificate = (
14- c509CertificateType: &c509CertificateTypeValues, ; Always 0
15- certificateSerialNumber: CertificateSerialNumber, ; Can be ignored/set to 0 or used as intended.
16- issuer: Name, ; This could be an on-chain reference to the issuer cert, what would be the best way? Transaction hash/cert hash?
17- validityNotBefore: Time, ; c509 uses UTC
18- validityNotAfter: Time, ; c509 uses UTC
19- subject: Name, ; Reference to on-chain keys related to this certificate
20- subjectPublicKeyAlgorithm: AlgorithmIdentifier, ; Must be int(12) = Ed25519
21- subjectPublicKey: subjectPublicKey, ; Ed25519 public key
22- extensions: Extensions, ; No extensions are currently supported must be set to []
23- issuerSignatureAlgorithm: AlgorithmIdentifier, ; Must be int(12) = Ed25519
17+ c509CertificateType: int, ; Always 2 as a natively signed
18+ certificateSerialNumber: CertificateSerialNumber, ; Can be ignored/set to 0 or used as intended.
19+ issuerSignatureAlgorithm: AlgorithmIdentifier, ; Must be int(12) = Ed25519
20+ issuer: Name / null, ; If the 'issuer' field is identical to the 'subject' field (in case of self-signed), then it must be encoded as CBOR null
21+ ; This could be an on-chain reference to the issuer cert. What would be the best way? Transaction hash/cert hash?
22+ validityNotBefore: ~time, ; c509 uses UTC
23+ validityNotAfter: ~time / null, ; c509 uses UTC, no expiration date must be set to null
24+ subject: Name, ; Reference to on-chain keys related to this certificate
25+ subjectPublicKeyAlgorithm: AlgorithmIdentifier, ; Must be int(12) = Ed25519
26+ subjectPublicKey: subjectPublicKey, ; Ed25519 public key
27+ extensions: Extensions ; Set to [] if no Extensions provided
2428)
2529
26- ; 0 = Native CBOR Certificate type
27- ; 1 = reencoded-der-cert - Not supported in this restricted version of the format.
28- c509CertificateTypeValues = ( native-cbor: 0,
29- ; reencoded-der: 1 ; Not supported in this restricted encoding format
30- )
31-
32- CertificateSerialNumber = biguint
33-
34- Name = [ * RelativeDistinguishedName ]
35- / text
36- / bytes
37-
38- RelativeDistinguishedName = Attribute / [ 2* Attribute ]
30+ CertificateSerialNumber = ~biguint
3931
40- Attribute = (
41- ( attributeType: int, attributeValue: text )
42- // ( attributeType: oid, attributeValue: bytes )
43- // ( attributeType: pen, attributeValue: bytes )
44- // CardanoPublicKey
45- )
46-
47- subjectPublicKey = bytes .size (32..32); Ed25519 public key stored in bytes, adjust size of this if other key types are supported.
32+ ; Currently ONLY AlgorithmIdentifier int(12) - Ed25519 is supported.
33+ ; oid and [ algorithm: oid, parameters: bytes ] are not supported by Plutus.
34+ AlgorithmIdentifier = int / ~oid / [ algorithm: ~oid, parameters: bytes ]
4835
49- ; This is a completely custom Attribute for the RelativeDistinguishedName which is only for use with Plutus scripts.
50- ; attributeType = The type of Cardano key we associate with this certificate.
51- ; proof = Does the transaction require proof that the key is owned by the transaction signer?
52- ; attributeValue = The Cardano public key hash of the attribute type
36+ Name = [ * Attribute ] / text / bytes
5337
54- CardanoPublicKey = ( attributeType: &cardanoKeyTypes proof: bool, attributeValue: bytes .size (28..28) )
38+ Attribute = ( attributeType: int, attributeValue: text )
39+ // ( attributeType: ~oid, attributeValue: bytes )
5540
56- cardanoKeyTypes = (
57- paymentKeyHash: 0,
58- stakeKeyHash: 1,
59- drepVerificationKeyHash: 2,
60- ccColdVerificationKeyHash: 3,
61- ccHotVerificationKeyHash: 4,
62- )
41+ subjectPublicKey = bytes .size (32..32) ; Ed25519 public key stored in bytes, adjust size if other key types are supported.
6342
64- ; Plutus will need to convert the Unix epoch timestamp to the nearest slot number
43+ ; For ~time, Plutus will need to convert the Unix epoch timestamp to the nearest slot number
6544; validityNotBefore rounds up to the next Slot after that time.
6645; validityNotAfter rounds down to the next Slot before that time.
67- Time = ( ~time / null )
68-
69- ed25519Signature = bstr .size 64; Ed25519 signature must be tagged to identify their type.
7046
47+ ed25519Signature = bstr .size 64 ; Ed25519 signature must be tagged to identify their type.
7148
72- ; Currently ONLY AlgorithmIdentifier int(12) - Ed25519 is supported.
73- ; oid and [ algorithm: oid, parameters: bytes ] are not supported by Plutus .
74- AlgorithmIdentifier = (int
75- / ~oid
76- / [ algorithm: ~oid, parameters: bytes ])
49+ ; The only Extension supported is int(3) = SubjectAltName where GeneralNames need to be
50+ ; int(6) = uniformResourceIdentifier .
51+ ; This uniformResourceIdentifier must conform to the URI based line in CIP-0134:
52+ ; https://github.com/input-output-hk/catalyst-CIPs/tree/cip13-simple-cardano-address-extension/CIP-0134
53+ ; for example, web+cardano://addr/stake1uyehkck0lajq8gr28t9uxnuvgcqrc6070x3k9r8048z8y5gh6ffgw
7754
78- ; Extensions are not currently supported by plutus and should be set to []
79- ; Any extensions present in the certificate will be ignored by plutus scripts.
8055Extensions = [ * Extension ] / int
8156
8257Extension = (
83- ( extensionID: int, extensionValue: any )
84- // ( extensionID: ~oid, ? critical: true, extensionValue: bytes )
85- // ( extensionID: pen, ? critical: true, extensionValue: bytes )
58+ ( extensionID: int, extensionValue: any )
59+ // ( extensionID: ~oid, ? critical: true, extensionValue: bytes )
8660)
61+
62+ SubjectAltName = GeneralNames / text
63+ GeneralNames = [ + GeneralName ]
64+ GeneralName = ( GeneralNameType: int, GeneralNameValue: any )
0 commit comments