@mikeargento/bitgraph-verify 1.14.0 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__tests__/carrier.test.js +19 -0
- package/dist/__tests__/carrier.test.js.map +1 -1
- package/dist/__tests__/carrier2.test.d.ts +2 -0
- package/dist/__tests__/carrier2.test.d.ts.map +1 -0
- package/dist/__tests__/carrier2.test.js +172 -0
- package/dist/__tests__/carrier2.test.js.map +1 -0
- package/dist/__tests__/settlement.test.d.ts +12 -0
- package/dist/__tests__/settlement.test.d.ts.map +1 -0
- package/dist/__tests__/settlement.test.js +185 -0
- package/dist/__tests__/settlement.test.js.map +1 -0
- package/dist/carrier-assemble.d.ts +33 -0
- package/dist/carrier-assemble.d.ts.map +1 -0
- package/dist/carrier-assemble.js +57 -0
- package/dist/carrier-assemble.js.map +1 -0
- package/dist/carrier-verify.d.ts +47 -1
- package/dist/carrier-verify.d.ts.map +1 -1
- package/dist/carrier-verify.js +292 -53
- package/dist/carrier-verify.js.map +1 -1
- package/dist/carrier.d.ts +93 -3
- package/dist/carrier.d.ts.map +1 -1
- package/dist/carrier.js +144 -19
- package/dist/carrier.js.map +1 -1
- package/dist/ceiling.js +2 -2
- package/dist/fuse-member.js +2 -2
- package/dist/fuse-member.js.map +1 -1
- package/dist/fuse-verify.js +3 -3
- package/dist/fuse-verify.js.map +1 -1
- package/dist/fuse.d.ts +34 -2
- package/dist/fuse.d.ts.map +1 -1
- package/dist/fuse.js +83 -6
- package/dist/fuse.js.map +1 -1
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -2
- package/dist/index.js.map +1 -1
- package/dist/nitro.d.ts +128 -0
- package/dist/nitro.d.ts.map +1 -0
- package/dist/nitro.js +551 -0
- package/dist/nitro.js.map +1 -0
- package/dist/settlement.d.ts +114 -0
- package/dist/settlement.d.ts.map +1 -0
- package/dist/settlement.js +194 -0
- package/dist/settlement.js.map +1 -0
- package/package.json +1 -1
- package/src/__tests__/carrier.test.ts +18 -0
- package/src/__tests__/carrier2.test.ts +193 -0
- package/src/__tests__/fixtures/carrier2/ceiling-26088459.witness.json +1 -0
- package/src/__tests__/fixtures/carrier2/ceiling-4548.anchor.json +1 -0
- package/src/__tests__/fixtures/carrier2/demo4546.ceiling.json +106 -0
- package/src/__tests__/fixtures/carrier2/demo4546.proof.json +47 -0
- package/src/__tests__/fixtures/carrier2/demo4546.txt +29 -0
- package/src/__tests__/fixtures/carrier2/floor-26088457.witness.json +1 -0
- package/src/__tests__/fixtures/carrier2/floor-4542.anchor.json +1 -0
- package/src/__tests__/fixtures/settlement/pointer-51979918-tx1.json +39 -0
- package/src/__tests__/fixtures/settlement/pointer-51979918.json +69 -0
- package/src/__tests__/settlement.test.ts +215 -0
- package/src/carrier-assemble.ts +74 -0
- package/src/carrier-verify.ts +328 -47
- package/src/carrier.ts +174 -18
- package/src/ceiling.ts +2 -2
- package/src/fuse-member.ts +2 -2
- package/src/fuse-verify.ts +3 -3
- package/src/fuse.ts +93 -6
- package/src/index.ts +30 -2
- package/src/nitro.ts +602 -0
- package/src/settlement.ts +263 -0
package/dist/nitro.d.ts
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS Nitro Enclaves Root CA G1 (CN=aws.nitro-enclaves, O=Amazon), valid
|
|
3
|
+
* 2019-10-28 to 2049-10-28. Published by AWS at
|
|
4
|
+
* https://aws-nitro-enclaves.amazonaws.com/AWS_NitroEnclaves_Root-G1.zip
|
|
5
|
+
*/
|
|
6
|
+
export declare const AWS_NITRO_ROOT_CA_PEM = "-----BEGIN CERTIFICATE-----\nMIICETCCAZagAwIBAgIRAPkxdWgbkK/hHUbMtOTn+FYwCgYIKoZIzj0EAwMwSTEL\nMAkGA1UEBhMCVVMxDzANBgNVBAoMBkFtYXpvbjEMMAoGA1UECwwDQVdTMRswGQYD\nVQQDDBJhd3Mubml0cm8tZW5jbGF2ZXMwHhcNMTkxMDI4MTMyODA1WhcNNDkxMDI4\nMTQyODA1WjBJMQswCQYDVQQGEwJVUzEPMA0GA1UECgwGQW1hem9uMQwwCgYDVQQL\nDANBV1MxGzAZBgNVBAMMEmF3cy5uaXRyby1lbmNsYXZlczB2MBAGByqGSM49AgEG\nBSuBBAAiA2IABPwCVOumCMHzaHDimtqQvkY4MpJzbolL//Zy2YlES1BR5TSksfbb\n48C8WBoyt7F2Bw7eEtaaP+ohG2bnUs990d0JX28TcPQXCEPZ3BABIeTPYwEoCWZE\nh8l5YoQwTcU/9KNCMEAwDwYDVR0TAQH/BAUwAwEB/zAdBgNVHQ4EFgQUkCW1DdkF\nR+eWw5b6cp3PmanfS5YwDgYDVR0PAQH/BAQDAgGGMAoGCCqGSM49BAMDA2kAMGYC\nMQCjfy+Rocm9Xue4YnwWmNJVA44fA0P5W2OpYow9OYCVRaEevL8uO1XYru5xtMPW\nrfMCMQCi85sWBbJwKKXdS6BptQFuZbT73o/gBh1qUxl/nNr12UO8Yfwr6wPLb+6N\nIwLz3/Y=\n-----END CERTIFICATE-----";
|
|
7
|
+
export declare function awsNitroRootDer(): Uint8Array;
|
|
8
|
+
/** SHA-256 of the root's DER, uppercase hex, computed from the embedded certificate (never typed in). */
|
|
9
|
+
export declare function awsNitroRootSha256(): string;
|
|
10
|
+
export interface NitroDocument {
|
|
11
|
+
moduleId: string | null;
|
|
12
|
+
/** The document's own signed clock, milliseconds since the epoch. */
|
|
13
|
+
timestampMs: number | null;
|
|
14
|
+
/** Every PCR as hex, index 0 to 15, including the zero ones. */
|
|
15
|
+
pcrs: Record<number, string>;
|
|
16
|
+
userData: Uint8Array | null;
|
|
17
|
+
nonce: Uint8Array | null;
|
|
18
|
+
publicKey: Uint8Array | null;
|
|
19
|
+
/** The leaf certificate, DER. */
|
|
20
|
+
certificate: Uint8Array;
|
|
21
|
+
/** The chain above the leaf as the document lists it: [root, intermediates...], DER. */
|
|
22
|
+
cabundle: Uint8Array[];
|
|
23
|
+
}
|
|
24
|
+
export interface NitroDecoded {
|
|
25
|
+
protectedHeader: Uint8Array;
|
|
26
|
+
payload: Uint8Array;
|
|
27
|
+
/** Raw r||s, 96 bytes. */
|
|
28
|
+
signature: Uint8Array;
|
|
29
|
+
/** The bytes the signature covers (RFC 9052 §4.4). */
|
|
30
|
+
sigStructure: Uint8Array;
|
|
31
|
+
doc: NitroDocument;
|
|
32
|
+
}
|
|
33
|
+
/** Decode a base64 attestation document. Throws on anything that is not a COSE_Sign1 over a Nitro map. */
|
|
34
|
+
export declare function decodeNitroAttestation(reportB64: string): NitroDecoded;
|
|
35
|
+
export interface NitroCheck {
|
|
36
|
+
name: string;
|
|
37
|
+
pass: boolean;
|
|
38
|
+
detail: string;
|
|
39
|
+
}
|
|
40
|
+
export interface NitroVerifyOptions {
|
|
41
|
+
/** The proof's environment.measurement; when given, PCR0 must equal it. */
|
|
42
|
+
expectedPcr0?: string;
|
|
43
|
+
/** The SHA-256 of the proof's canonical signed body, base64; when given, user_data must equal it. */
|
|
44
|
+
expectedUserDataB64?: string;
|
|
45
|
+
/** Another trust root, DER, for a verifier that pins its own. Default: the embedded AWS root. */
|
|
46
|
+
rootDer?: Uint8Array;
|
|
47
|
+
}
|
|
48
|
+
export interface NitroVerifyResult {
|
|
49
|
+
valid: boolean;
|
|
50
|
+
checks: NitroCheck[];
|
|
51
|
+
doc: NitroDocument | null;
|
|
52
|
+
/** SHA-256 of the root the chain was checked against, uppercase hex. */
|
|
53
|
+
rootSha256: string;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Every check, in order, each stated as a verdict. The document's own
|
|
57
|
+
* timestamp is the instant the certificates are evaluated at.
|
|
58
|
+
*/
|
|
59
|
+
export declare function verifyNitroAttestation(reportB64: string, opts?: NitroVerifyOptions): NitroVerifyResult;
|
|
60
|
+
export declare const ATTESTATION_WITNESS_FORMAT = "aws-nitro-witness/1";
|
|
61
|
+
export interface AttestationWitness {
|
|
62
|
+
format: typeof ATTESTATION_WITNESS_FORMAT;
|
|
63
|
+
/** The bytes the ES384 signature covers (RFC 9052 Sig_structure), base64. */
|
|
64
|
+
sigStructureB64: string;
|
|
65
|
+
/** The signature as COSE carries it, r||s, hex. */
|
|
66
|
+
signatureRawHex: string;
|
|
67
|
+
/** The same signature DER-encoded, hex, for openssl. */
|
|
68
|
+
signatureDerHex: string;
|
|
69
|
+
/** Leaf first, then each certificate above it, up to (not including) the root. PEM. */
|
|
70
|
+
chainPem: string[];
|
|
71
|
+
/** The AWS Nitro Enclaves Root CA G1, PEM, and its DER SHA-256. */
|
|
72
|
+
rootPem: string;
|
|
73
|
+
rootSha256: string;
|
|
74
|
+
/** The instant to evaluate the certificates at: the document's own timestamp. */
|
|
75
|
+
atTime: string;
|
|
76
|
+
atTimeUnix: number;
|
|
77
|
+
/** What the signed map says, decoded. */
|
|
78
|
+
decoded: {
|
|
79
|
+
moduleId: string | null;
|
|
80
|
+
timestampMs: number | null;
|
|
81
|
+
/** CBOR encoding of the timestamp inside the signed bytes (0x1b + 8 bytes), hex, for the presence check. */
|
|
82
|
+
timestampCborHex: string | null;
|
|
83
|
+
pcr0: string | null;
|
|
84
|
+
pcr1: string | null;
|
|
85
|
+
pcr2: string | null;
|
|
86
|
+
pcr3: string | null;
|
|
87
|
+
pcr4: string | null;
|
|
88
|
+
userDataHex: string | null;
|
|
89
|
+
userDataB64: string | null;
|
|
90
|
+
};
|
|
91
|
+
/** What the proof says each value must equal. */
|
|
92
|
+
expected: {
|
|
93
|
+
pcr0: string;
|
|
94
|
+
/** SHA-256 of the proof's canonical signed body, base64: what user_data must equal. */
|
|
95
|
+
signedBodyHashB64: string;
|
|
96
|
+
/** The ledger's proofHash, when it is the same value (a proof with no actor and no policy). */
|
|
97
|
+
proofHashB64?: string;
|
|
98
|
+
};
|
|
99
|
+
/** The check, as shell steps with their expected output. */
|
|
100
|
+
procedure: string[];
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Lay the attestation out as evidence. `expected.signedBodyHashB64` is the
|
|
104
|
+
* SHA-256 of the proof's canonical signed body (computeSignedBodyHash), the
|
|
105
|
+
* value user_data must equal; `expected.pcr0` is the proof's measurement.
|
|
106
|
+
*/
|
|
107
|
+
export declare function attestationWitness(reportB64: string, expected: {
|
|
108
|
+
pcr0: string;
|
|
109
|
+
signedBodyHashB64: string;
|
|
110
|
+
proofHashB64?: string;
|
|
111
|
+
}): AttestationWitness;
|
|
112
|
+
/**
|
|
113
|
+
* Check a witness against the attestation it claims to lay out: every derived
|
|
114
|
+
* field must be what this module derives from reportB64 itself. A witness is
|
|
115
|
+
* convenience for a reader with openssl; it is never trusted over the document.
|
|
116
|
+
*/
|
|
117
|
+
export declare function witnessMatchesAttestation(w: AttestationWitness, reportB64: string): {
|
|
118
|
+
ok: boolean;
|
|
119
|
+
detail: string;
|
|
120
|
+
};
|
|
121
|
+
/** RFC 9052 §4.4: ["Signature1", protected, external_aad = h'', payload]. */
|
|
122
|
+
export declare function encodeSigStructure(protectedHeader: Uint8Array, payload: Uint8Array): Uint8Array;
|
|
123
|
+
/** r||s → DER SEQUENCE { INTEGER r, INTEGER s }, the form openssl reads. */
|
|
124
|
+
export declare function rawEcdsaSigToDer(raw: Uint8Array): Uint8Array;
|
|
125
|
+
export declare function bytesToHex(b: Uint8Array): string;
|
|
126
|
+
export declare function derToPem(der: Uint8Array): string;
|
|
127
|
+
export declare function pemToDer(pem: string): Uint8Array;
|
|
128
|
+
//# sourceMappingURL=nitro.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nitro.d.ts","sourceRoot":"","sources":["../src/nitro.ts"],"names":[],"mappings":"AAgCA;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,2xBAaR,CAAC;AAE3B,wBAAgB,eAAe,IAAI,UAAU,CAE5C;AAED,yGAAyG;AACzG,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAID,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,GAAG,I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