@degenerate/sharedata 0.4.0 → 0.6.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/persistence/deserialize-share-data.d.ts.map +1 -1
- package/dist/persistence/deserialize-share-data.js +1 -1
- package/dist/share-data/creation/create-share-data-initial-crypto.d.ts +4 -5
- package/dist/share-data/creation/create-share-data-initial-crypto.d.ts.map +1 -1
- package/dist/share-data/creation/create-share-data-initial-crypto.js +6 -7
- package/dist/share-data/proofs/creation/build-transaction-proposal-signer.d.ts +5 -10
- package/dist/share-data/proofs/creation/build-transaction-proposal-signer.d.ts.map +1 -1
- package/dist/share-data/proofs/creation/build-transaction-proposal-signer.js +1 -3
- package/dist/share-data/proofs/creation/create-share-data-proposal-proof.d.ts +3 -4
- package/dist/share-data/proofs/creation/create-share-data-proposal-proof.d.ts.map +1 -1
- package/dist/share-data/proofs/creation/create-share-data-proposal-proof.js +5 -6
- package/dist/share-data/proofs/creation/create-transaction-proposal-proof.d.ts +3 -4
- package/dist/share-data/proofs/creation/create-transaction-proposal-proof.d.ts.map +1 -1
- package/dist/share-data/proofs/creation/create-transaction-proposal-proof.js +5 -6
- package/dist/share-data/proofs/testing/test-proof-signer.d.ts +8 -8
- package/dist/share-data/proofs/testing/test-proof-signer.d.ts.map +1 -1
- package/dist/share-data/proofs/testing/test-proof-signer.js +17 -19
- package/dist/share-data/proofs/verification/verify-share-data-proposal-proof.d.ts +4 -6
- package/dist/share-data/proofs/verification/verify-share-data-proposal-proof.d.ts.map +1 -1
- package/dist/share-data/proofs/verification/verify-share-data-proposal-proof.js +8 -57
- package/dist/share-data/proofs/verification/verify-transaction-proposal-proof.d.ts +4 -4
- package/dist/share-data/proofs/verification/verify-transaction-proposal-proof.d.ts.map +1 -1
- package/dist/share-data/proofs/verification/verify-transaction-proposal-proof.js +8 -54
- package/dist/share-data/share-data.d.ts +2 -2
- package/dist/share-data/share-data.d.ts.map +1 -1
- package/dist/share-data/share-data.js +4 -4
- package/package.json +4 -4
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deserialize-share-data.d.ts","sourceRoot":"","sources":["../../src/persistence/deserialize-share-data.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAYrD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,GAAI,UAAU,OAAO,KAAG,
|
|
1
|
+
{"version":3,"file":"deserialize-share-data.d.ts","sourceRoot":"","sources":["../../src/persistence/deserialize-share-data.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAYrD;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,GAAI,UAAU,OAAO,KAAG,SAoHxD,CAAC"}
|
|
@@ -84,7 +84,7 @@ const deserializeShareData = (snapshot) => {
|
|
|
84
84
|
// throws ShareDataTransactionProofFailedError here rather than being
|
|
85
85
|
// loaded. Verifying before the apply keeps the recomputed current hash
|
|
86
86
|
// aligned with what the signer signed over.
|
|
87
|
-
(0, verify_transaction_proposal_proof_1.verifyTransactionProposalProof)(entry.proof, block, entry.proposedState
|
|
87
|
+
(0, verify_transaction_proposal_proof_1.verifyTransactionProposalProof)(entry.proof, block, entry.proposedState);
|
|
88
88
|
// addTransactionAlreadyValidated derives its accept/reject outcome
|
|
89
89
|
// from (proposedResult && currentResult). Setting both to the stored
|
|
90
90
|
// boolean replays the original outcome exactly: currentState is
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IShareDataInitialCryptoData } from '@degenerate/generic';
|
|
2
2
|
import { ShareData } from '../share-data';
|
|
3
3
|
/**
|
|
4
4
|
* This function creates the initial crypto data for the share data.
|
|
5
5
|
*
|
|
6
|
-
* @param
|
|
6
|
+
* @param privateKey the 32-byte Ed25519 secret seed (hex) to sign with
|
|
7
|
+
* @param shareData the share data to create the initial crypto for
|
|
7
8
|
*/
|
|
8
|
-
export declare const createShareDataInitialCrypto: (privateKey: string,
|
|
9
|
-
shareData: ShareData, // the share data to create the initial crypto for
|
|
10
|
-
signingCurve?: EllipticalCurvesSigning) => IShareDataInitialCryptoData;
|
|
9
|
+
export declare const createShareDataInitialCrypto: (privateKey: string, shareData: ShareData) => IShareDataInitialCryptoData;
|
|
11
10
|
//# sourceMappingURL=create-share-data-initial-crypto.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-share-data-initial-crypto.d.ts","sourceRoot":"","sources":["../../../src/share-data/creation/create-share-data-initial-crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,
|
|
1
|
+
{"version":3,"file":"create-share-data-initial-crypto.d.ts","sourceRoot":"","sources":["../../../src/share-data/creation/create-share-data-initial-crypto.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,2BAA2B,EAC9B,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,GACrC,YAAY,MAAM,EAClB,WAAW,SAAS,KACrB,2BAYF,CAAA"}
|
|
@@ -6,17 +6,16 @@ const calculate_share_data_string_1 = require("../helpers/calculate-share-data-s
|
|
|
6
6
|
/**
|
|
7
7
|
* This function creates the initial crypto data for the share data.
|
|
8
8
|
*
|
|
9
|
-
* @param
|
|
9
|
+
* @param privateKey the 32-byte Ed25519 secret seed (hex) to sign with
|
|
10
|
+
* @param shareData the share data to create the initial crypto for
|
|
10
11
|
*/
|
|
11
|
-
const createShareDataInitialCrypto = (privateKey,
|
|
12
|
-
|
|
13
|
-
signingCurve = generic_1.EllipticalCurvesSigning.Curve25519) => {
|
|
14
|
-
const keyPair = (0, generic_1.createKeyPairFromPrivateKey)(signingCurve, privateKey);
|
|
12
|
+
const createShareDataInitialCrypto = (privateKey, shareData) => {
|
|
13
|
+
const publicKey = (0, generic_1.getEd25519PublicKeyFromPrivateKey)(privateKey);
|
|
15
14
|
const shareDataString = (0, calculate_share_data_string_1.calculateShareDataString)(shareData);
|
|
16
15
|
const shareDataHash = (0, generic_1.calculateHash)(shareDataString);
|
|
17
|
-
const shareDataSignature = (0, generic_1.
|
|
16
|
+
const shareDataSignature = (0, generic_1.createEd25519Signature)(privateKey, shareDataHash);
|
|
18
17
|
const initialCryptoData = {
|
|
19
|
-
publicKey
|
|
18
|
+
publicKey,
|
|
20
19
|
shareDataHash,
|
|
21
20
|
shareDataSignature,
|
|
22
21
|
timestamp: Date.now(),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IShareData, IShareDataCryptoProof } from '@degenerate/generic';
|
|
2
2
|
import { ShareData } from '../../share-data';
|
|
3
3
|
/**
|
|
4
4
|
* Configuration for the production transaction-proposal signer returned by
|
|
@@ -6,18 +6,13 @@ import { ShareData } from '../../share-data';
|
|
|
6
6
|
*/
|
|
7
7
|
export interface ITransactionProposalSignerConfig {
|
|
8
8
|
/**
|
|
9
|
-
* Hex-encoded
|
|
10
|
-
* (must correspond to its `creationPublicKey`). Captured in the
|
|
11
|
-
* closure and never leaves it. In production this should come from
|
|
12
|
-
* secure key manager (KMS / HSM / encrypted environment value), not a
|
|
9
|
+
* Hex-encoded 32-byte Ed25519 secret seed authorized to mutate the target
|
|
10
|
+
* share-data (must correspond to its `creationPublicKey`). Captured in the
|
|
11
|
+
* returned closure and never leaves it. In production this should come from
|
|
12
|
+
* a secure key manager (KMS / HSM / encrypted environment value), not a
|
|
13
13
|
* literal string in code.
|
|
14
14
|
*/
|
|
15
15
|
privateKey: string;
|
|
16
|
-
/**
|
|
17
|
-
* Elliptical curve to sign with. Defaults to `Curve25519`, matching the
|
|
18
|
-
* `ShareData` constructor default.
|
|
19
|
-
*/
|
|
20
|
-
curve?: EllipticalCurvesSigning;
|
|
21
16
|
}
|
|
22
17
|
/**
|
|
23
18
|
* A bound signer that mints a transaction proposal proof authorizing one
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build-transaction-proposal-signer.d.ts","sourceRoot":"","sources":["../../../../src/share-data/proofs/creation/build-transaction-proposal-signer.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,
|
|
1
|
+
{"version":3,"file":"build-transaction-proposal-signer.d.ts","sourceRoot":"","sources":["../../../../src/share-data/proofs/creation/build-transaction-proposal-signer.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,UAAU,EACV,qBAAqB,EACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAG7C;;;GAGG;AACH,MAAM,WAAW,gCAAgC;IAC7C;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAC;CACtB;AAED;;;;;;GAMG;AACH,MAAM,MAAM,yBAAyB,GAAG,CACpC,aAAa,EAAE,UAAU,EACzB,UAAU,EAAE,MAAM,EAClB,SAAS,EAAE,SAAS,KACnB,qBAAqB,CAAC;AAE3B;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,8BAA8B,GACvC,QAAQ,gCAAgC,KACzC,yBAQF,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.buildTransactionProposalSigner = void 0;
|
|
4
|
-
const generic_1 = require("@degenerate/generic");
|
|
5
4
|
const create_transaction_proposal_proof_1 = require("./create-transaction-proposal-proof");
|
|
6
5
|
/**
|
|
7
6
|
* Returns a production-ready {@link TransactionProposalSigner} that signs each
|
|
@@ -30,7 +29,6 @@ const create_transaction_proposal_proof_1 = require("./create-transaction-propos
|
|
|
30
29
|
* replayed for a different amount or a different function.
|
|
31
30
|
*/
|
|
32
31
|
const buildTransactionProposalSigner = (config) => {
|
|
33
|
-
|
|
34
|
-
return (proposedState, functionId, shareData) => (0, create_transaction_proposal_proof_1.createTransactionProposalProof)(config.privateKey, shareData, proposedState, functionId, curve);
|
|
32
|
+
return (proposedState, functionId, shareData) => (0, create_transaction_proposal_proof_1.createTransactionProposalProof)(config.privateKey, shareData, proposedState, functionId);
|
|
35
33
|
};
|
|
36
34
|
exports.buildTransactionProposalSigner = buildTransactionProposalSigner;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IShareDataAdditionalValuesToInclude, IShareDataCryptoProof } from '@degenerate/generic';
|
|
2
2
|
import { ShareData } from '../../share-data';
|
|
3
3
|
/**
|
|
4
4
|
* This function creates a share data proposal proof.
|
|
5
|
-
* @param privateKey the
|
|
5
|
+
* @param privateKey the 32-byte Ed25519 secret seed (hex) to sign the proof with
|
|
6
6
|
* @param shareData the share data object
|
|
7
7
|
* @param additionalValuesToInclude the additional values to include in the share data string
|
|
8
|
-
* @param ellipticalCurve the elliptical curve to use for signing
|
|
9
8
|
* @returns
|
|
10
9
|
*/
|
|
11
|
-
export declare const createShareDataProposalProof: (privateKey: string, shareData: ShareData, additionalValuesToInclude: IShareDataAdditionalValuesToInclude
|
|
10
|
+
export declare const createShareDataProposalProof: (privateKey: string, shareData: ShareData, additionalValuesToInclude: IShareDataAdditionalValuesToInclude) => IShareDataCryptoProof;
|
|
12
11
|
//# sourceMappingURL=create-share-data-proposal-proof.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-share-data-proposal-proof.d.ts","sourceRoot":"","sources":["../../../../src/share-data/proofs/creation/create-share-data-proposal-proof.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,
|
|
1
|
+
{"version":3,"file":"create-share-data-proposal-proof.d.ts","sourceRoot":"","sources":["../../../../src/share-data/proofs/creation/create-share-data-proposal-proof.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,mCAAmC,EACnC,qBAAqB,EACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAI7C;;;;;;GAMG;AACH,eAAO,MAAM,4BAA4B,GACrC,YAAY,MAAM,EAClB,WAAW,SAAS,EACpB,2BAA2B,mCAAmC,KAC/D,qBA0BF,CAAC"}
|
|
@@ -7,23 +7,22 @@ const get_previous_hash_from_share_data_1 = require("../helpers/get-previous-has
|
|
|
7
7
|
const create_share_data_string_to_sign_1 = require("../helpers/create-share-data-string-to-sign");
|
|
8
8
|
/**
|
|
9
9
|
* This function creates a share data proposal proof.
|
|
10
|
-
* @param privateKey the
|
|
10
|
+
* @param privateKey the 32-byte Ed25519 secret seed (hex) to sign the proof with
|
|
11
11
|
* @param shareData the share data object
|
|
12
12
|
* @param additionalValuesToInclude the additional values to include in the share data string
|
|
13
|
-
* @param ellipticalCurve the elliptical curve to use for signing
|
|
14
13
|
* @returns
|
|
15
14
|
*/
|
|
16
|
-
const createShareDataProposalProof = (privateKey, shareData, additionalValuesToInclude
|
|
17
|
-
const
|
|
15
|
+
const createShareDataProposalProof = (privateKey, shareData, additionalValuesToInclude) => {
|
|
16
|
+
const publicKey = (0, generic_1.getEd25519PublicKeyFromPrivateKey)(privateKey);
|
|
18
17
|
const shareDataString = (0, calculate_share_data_string_1.calculateShareDataString)(shareData, undefined, additionalValuesToInclude);
|
|
19
18
|
const shareDataPreviousHash = (0, get_previous_hash_from_share_data_1.getPreviousHashFromShareData)(shareData);
|
|
20
19
|
const shareDataHash = (0, generic_1.calculateHash)(shareDataString);
|
|
21
20
|
const currentTimestamp = Date.now();
|
|
22
21
|
// calculate the current signature for the share data proof
|
|
23
22
|
const shareDataSignatureString = (0, create_share_data_string_to_sign_1.createShareDataStringToSign)(shareDataHash, shareDataPreviousHash, currentTimestamp);
|
|
24
|
-
const shareDataSignature = (0, generic_1.
|
|
23
|
+
const shareDataSignature = (0, generic_1.createEd25519Signature)(privateKey, shareDataSignatureString);
|
|
25
24
|
const shareDataCryptoProof = {
|
|
26
|
-
publicKey
|
|
25
|
+
publicKey,
|
|
27
26
|
shareDataHash,
|
|
28
27
|
shareDataPreviousHash,
|
|
29
28
|
shareDataSignature,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IShareData, IShareDataCryptoProof } from '@degenerate/generic';
|
|
2
2
|
import { ShareData } from '../../share-data';
|
|
3
3
|
/**
|
|
4
4
|
* Mint a transaction proposal proof: a signed attestation that the holder of
|
|
@@ -17,11 +17,10 @@ import { ShareData } from '../../share-data';
|
|
|
17
17
|
* state it is handed at apply time, so it never needs to be stored in the
|
|
18
18
|
* proof — keeping the wire / persistence / history shape unchanged.
|
|
19
19
|
*
|
|
20
|
-
* @param privateKey
|
|
20
|
+
* @param privateKey 32-byte Ed25519 secret seed (hex) authorized for this share-data
|
|
21
21
|
* @param shareData the share-data the transaction will mutate
|
|
22
22
|
* @param proposedState the exact state the function proposes to apply
|
|
23
23
|
* @param functionId stable id of the function producing `proposedState`
|
|
24
|
-
* @param ellipticalCurve the signing curve (defaults to Curve25519)
|
|
25
24
|
*/
|
|
26
|
-
export declare const createTransactionProposalProof: (privateKey: string, shareData: ShareData, proposedState: IShareData, functionId: string
|
|
25
|
+
export declare const createTransactionProposalProof: (privateKey: string, shareData: ShareData, proposedState: IShareData, functionId: string) => IShareDataCryptoProof;
|
|
27
26
|
//# sourceMappingURL=create-transaction-proposal-proof.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-transaction-proposal-proof.d.ts","sourceRoot":"","sources":["../../../../src/share-data/proofs/creation/create-transaction-proposal-proof.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,
|
|
1
|
+
{"version":3,"file":"create-transaction-proposal-proof.d.ts","sourceRoot":"","sources":["../../../../src/share-data/proofs/creation/create-transaction-proposal-proof.ts"],"names":[],"mappings":"AAAA,OAAO,EAIH,UAAU,EACV,qBAAqB,EACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAK7C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,8BAA8B,GACvC,YAAY,MAAM,EAClB,WAAW,SAAS,EACpB,eAAe,UAAU,EACzB,YAAY,MAAM,KACnB,qBAkCF,CAAC"}
|
|
@@ -23,17 +23,16 @@ const hash_proposed_state_1 = require("../helpers/hash-proposed-state");
|
|
|
23
23
|
* state it is handed at apply time, so it never needs to be stored in the
|
|
24
24
|
* proof — keeping the wire / persistence / history shape unchanged.
|
|
25
25
|
*
|
|
26
|
-
* @param privateKey
|
|
26
|
+
* @param privateKey 32-byte Ed25519 secret seed (hex) authorized for this share-data
|
|
27
27
|
* @param shareData the share-data the transaction will mutate
|
|
28
28
|
* @param proposedState the exact state the function proposes to apply
|
|
29
29
|
* @param functionId stable id of the function producing `proposedState`
|
|
30
|
-
* @param ellipticalCurve the signing curve (defaults to Curve25519)
|
|
31
30
|
*/
|
|
32
|
-
const createTransactionProposalProof = (privateKey, shareData, proposedState, functionId
|
|
31
|
+
const createTransactionProposalProof = (privateKey, shareData, proposedState, functionId) => {
|
|
33
32
|
if (typeof functionId !== 'string' || functionId.length < 1) {
|
|
34
33
|
throw new Error('createTransactionProposalProof: functionId is required and must be a non-empty string');
|
|
35
34
|
}
|
|
36
|
-
const
|
|
35
|
+
const publicKey = (0, generic_1.getEd25519PublicKeyFromPrivateKey)(privateKey);
|
|
37
36
|
// Current-state hash uses functionId as the purpose, mirroring how the
|
|
38
37
|
// verifier recomputes it from `proof.purpose`.
|
|
39
38
|
const currentString = (0, calculate_share_data_string_1.calculateShareDataString)(shareData, undefined, { purpose: functionId });
|
|
@@ -42,11 +41,11 @@ const createTransactionProposalProof = (privateKey, shareData, proposedState, fu
|
|
|
42
41
|
const previousHash = (0, get_previous_hash_from_share_data_1.getPreviousHashFromShareData)(shareData);
|
|
43
42
|
const timestamp = Date.now();
|
|
44
43
|
const signedString = (0, create_transaction_proposal_string_to_sign_1.createTransactionProposalStringToSign)(currentHash, proposedStateHash, functionId, previousHash, timestamp);
|
|
45
|
-
const signature = (0, generic_1.
|
|
44
|
+
const signature = (0, generic_1.createEd25519Signature)(privateKey, signedString);
|
|
46
45
|
// Field order mirrors IShareDataCryptoProofSchema exactly — load-bearing,
|
|
47
46
|
// see the schema docs in share-data-crypto-models.ts.
|
|
48
47
|
const proof = {
|
|
49
|
-
publicKey
|
|
48
|
+
publicKey,
|
|
50
49
|
shareDataHash: currentHash,
|
|
51
50
|
shareDataPreviousHash: previousHash,
|
|
52
51
|
shareDataSignature: signature,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IShareData, IShareDataCryptoProof } from '@degenerate/generic';
|
|
2
2
|
import { ShareData } from '../../share-data';
|
|
3
3
|
/**
|
|
4
|
-
* Generate a fresh
|
|
5
|
-
* in tests. Returns the hex-encoded private and public
|
|
6
|
-
* can use the public half as the ShareData's `creationPublicKey` and the
|
|
4
|
+
* Generate a fresh Ed25519 (EdDSA) keypair suitable for signing ShareData
|
|
5
|
+
* proofs in tests. Returns the hex-encoded private seed and public key so the
|
|
6
|
+
* caller can use the public half as the ShareData's `creationPublicKey` and the
|
|
7
7
|
* private half to mint real signed proofs.
|
|
8
8
|
*
|
|
9
9
|
* Test-only helper — not exported from the package barrel. Real signing
|
|
10
10
|
* keys must come from a key manager in production.
|
|
11
11
|
*/
|
|
12
|
-
export declare const generateTestSigningKey: (
|
|
12
|
+
export declare const generateTestSigningKey: () => {
|
|
13
13
|
privateKey: string;
|
|
14
14
|
publicKey: string;
|
|
15
15
|
};
|
|
@@ -24,7 +24,7 @@ export declare const generateTestSigningKey: (curve?: EllipticalCurvesSigning) =
|
|
|
24
24
|
* `buildEllipticalCurvesProofFor` from `@degenerate/shareblock` which
|
|
25
25
|
* handles the same plumbing through a documented public API.
|
|
26
26
|
*/
|
|
27
|
-
export declare const createTestProofFor: (privateKey: string
|
|
27
|
+
export declare const createTestProofFor: (privateKey: string) => (purpose: string, shareData: ShareData) => IShareDataCryptoProof;
|
|
28
28
|
/**
|
|
29
29
|
* Build a `(proposedState, functionId, shareData) => IShareDataCryptoProof`
|
|
30
30
|
* callback that mints a *transaction* proposal proof (binds the proposed
|
|
@@ -36,7 +36,7 @@ export declare const createTestProofFor: (privateKey: string, curve?: Elliptical
|
|
|
36
36
|
*
|
|
37
37
|
* Test-only helper. Production flows mint these from a key manager.
|
|
38
38
|
*/
|
|
39
|
-
export declare const createTestTransactionProofFor: (privateKey: string
|
|
39
|
+
export declare const createTestTransactionProofFor: (privateKey: string) => (proposedState: IShareData, functionId: string, shareData: ShareData) => IShareDataCryptoProof;
|
|
40
40
|
/**
|
|
41
41
|
* Convenience wrapper: generate a fresh signing keypair AND return a
|
|
42
42
|
* matching proof signer in one call. Returns both so the test can use the
|
|
@@ -44,7 +44,7 @@ export declare const createTestTransactionProofFor: (privateKey: string, curve?:
|
|
|
44
44
|
* structural proofs (addFunction/addRule); `transactionProofFor` mints
|
|
45
45
|
* runtime transaction proposal proofs.
|
|
46
46
|
*/
|
|
47
|
-
export declare const generateTestSigner: (
|
|
47
|
+
export declare const generateTestSigner: () => {
|
|
48
48
|
privateKey: string;
|
|
49
49
|
publicKey: string;
|
|
50
50
|
proofFor: ReturnType<typeof createTestProofFor>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-proof-signer.d.ts","sourceRoot":"","sources":["../../../../src/share-data/proofs/testing/test-proof-signer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test-proof-signer.d.ts","sourceRoot":"","sources":["../../../../src/share-data/proofs/testing/test-proof-signer.ts"],"names":[],"mappings":"AACA,OAAO,EAEH,UAAU,EACV,qBAAqB,EACxB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAK7C;;;;;;;;GAQG;AACH,eAAO,MAAM,sBAAsB,QAAO;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAMhF,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,kBAAkB,GAAI,YAAY,MAAM,MACzC,SAAS,MAAM,EAAE,WAAW,SAAS,KAAG,qBAOnD,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,6BAA6B,GAAI,YAAY,MAAM,MAExD,eAAe,UAAU,EACzB,YAAY,MAAM,EAClB,WAAW,SAAS,KACrB,qBAEN,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,QAAO;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;IAChD,mBAAmB,EAAE,UAAU,CAAC,OAAO,6BAA6B,CAAC,CAAC;CASzE,CAAC"}
|
|
@@ -34,27 +34,25 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.generateTestSigner = exports.createTestTransactionProofFor = exports.createTestProofFor = exports.generateTestSigningKey = void 0;
|
|
37
|
-
|
|
38
|
-
const elliptic = __importStar(require("elliptic"));
|
|
37
|
+
const crypto = __importStar(require("crypto"));
|
|
39
38
|
const generic_1 = require("@degenerate/generic");
|
|
40
39
|
const create_share_data_initial_crypto_1 = require("../../creation/create-share-data-initial-crypto");
|
|
41
40
|
const create_share_data_proposal_proof_1 = require("../creation/create-share-data-proposal-proof");
|
|
42
41
|
const create_transaction_proposal_proof_1 = require("../creation/create-transaction-proposal-proof");
|
|
43
42
|
/**
|
|
44
|
-
* Generate a fresh
|
|
45
|
-
* in tests. Returns the hex-encoded private and public
|
|
46
|
-
* can use the public half as the ShareData's `creationPublicKey` and the
|
|
43
|
+
* Generate a fresh Ed25519 (EdDSA) keypair suitable for signing ShareData
|
|
44
|
+
* proofs in tests. Returns the hex-encoded private seed and public key so the
|
|
45
|
+
* caller can use the public half as the ShareData's `creationPublicKey` and the
|
|
47
46
|
* private half to mint real signed proofs.
|
|
48
47
|
*
|
|
49
48
|
* Test-only helper — not exported from the package barrel. Real signing
|
|
50
49
|
* keys must come from a key manager in production.
|
|
51
50
|
*/
|
|
52
|
-
const generateTestSigningKey = (
|
|
53
|
-
const
|
|
54
|
-
const keyPair = ec.genKeyPair();
|
|
51
|
+
const generateTestSigningKey = () => {
|
|
52
|
+
const privateKey = crypto.randomBytes(32).toString('hex');
|
|
55
53
|
return {
|
|
56
|
-
privateKey
|
|
57
|
-
publicKey:
|
|
54
|
+
privateKey,
|
|
55
|
+
publicKey: (0, generic_1.getEd25519PublicKeyFromPrivateKey)(privateKey),
|
|
58
56
|
};
|
|
59
57
|
};
|
|
60
58
|
exports.generateTestSigningKey = generateTestSigningKey;
|
|
@@ -69,13 +67,13 @@ exports.generateTestSigningKey = generateTestSigningKey;
|
|
|
69
67
|
* `buildEllipticalCurvesProofFor` from `@degenerate/shareblock` which
|
|
70
68
|
* handles the same plumbing through a documented public API.
|
|
71
69
|
*/
|
|
72
|
-
const createTestProofFor = (privateKey
|
|
70
|
+
const createTestProofFor = (privateKey) => {
|
|
73
71
|
return (purpose, shareData) => {
|
|
74
72
|
if (!shareData.creationHash && shareData.structuralProofs.length === 0) {
|
|
75
|
-
const initialCrypto = (0, create_share_data_initial_crypto_1.createShareDataInitialCrypto)(privateKey, shareData
|
|
73
|
+
const initialCrypto = (0, create_share_data_initial_crypto_1.createShareDataInitialCrypto)(privateKey, shareData);
|
|
76
74
|
shareData.initializeCrypto(initialCrypto);
|
|
77
75
|
}
|
|
78
|
-
return (0, create_share_data_proposal_proof_1.createShareDataProposalProof)(privateKey, shareData, { purpose }
|
|
76
|
+
return (0, create_share_data_proposal_proof_1.createShareDataProposalProof)(privateKey, shareData, { purpose });
|
|
79
77
|
};
|
|
80
78
|
};
|
|
81
79
|
exports.createTestProofFor = createTestProofFor;
|
|
@@ -90,8 +88,8 @@ exports.createTestProofFor = createTestProofFor;
|
|
|
90
88
|
*
|
|
91
89
|
* Test-only helper. Production flows mint these from a key manager.
|
|
92
90
|
*/
|
|
93
|
-
const createTestTransactionProofFor = (privateKey
|
|
94
|
-
return (proposedState, functionId, shareData) => (0, create_transaction_proposal_proof_1.createTransactionProposalProof)(privateKey, shareData, proposedState, functionId
|
|
91
|
+
const createTestTransactionProofFor = (privateKey) => {
|
|
92
|
+
return (proposedState, functionId, shareData) => (0, create_transaction_proposal_proof_1.createTransactionProposalProof)(privateKey, shareData, proposedState, functionId);
|
|
95
93
|
};
|
|
96
94
|
exports.createTestTransactionProofFor = createTestTransactionProofFor;
|
|
97
95
|
/**
|
|
@@ -101,13 +99,13 @@ exports.createTestTransactionProofFor = createTestTransactionProofFor;
|
|
|
101
99
|
* structural proofs (addFunction/addRule); `transactionProofFor` mints
|
|
102
100
|
* runtime transaction proposal proofs.
|
|
103
101
|
*/
|
|
104
|
-
const generateTestSigner = (
|
|
105
|
-
const { privateKey, publicKey } = (0, exports.generateTestSigningKey)(
|
|
102
|
+
const generateTestSigner = () => {
|
|
103
|
+
const { privateKey, publicKey } = (0, exports.generateTestSigningKey)();
|
|
106
104
|
return {
|
|
107
105
|
privateKey,
|
|
108
106
|
publicKey,
|
|
109
|
-
proofFor: (0, exports.createTestProofFor)(privateKey
|
|
110
|
-
transactionProofFor: (0, exports.createTestTransactionProofFor)(privateKey
|
|
107
|
+
proofFor: (0, exports.createTestProofFor)(privateKey),
|
|
108
|
+
transactionProofFor: (0, exports.createTestTransactionProofFor)(privateKey),
|
|
111
109
|
};
|
|
112
110
|
};
|
|
113
111
|
exports.generateTestSigner = generateTestSigner;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IShareDataCryptoProof } from '@degenerate/generic';
|
|
2
2
|
import { ShareData } from '../../share-data';
|
|
3
3
|
/**
|
|
4
4
|
* Verifies that an `IShareDataCryptoProof` is a faithful attestation of the
|
|
@@ -12,10 +12,8 @@ import { ShareData } from '../../share-data';
|
|
|
12
12
|
* requires the private key).
|
|
13
13
|
*
|
|
14
14
|
* Synchronous on purpose — `addFunction` / `addRule` are synchronous and we
|
|
15
|
-
* don't want to cascade-async every caller in the codebase.
|
|
16
|
-
* `
|
|
17
|
-
* project's existing `verifyCryptoSignatureByHash` wrapper is `async` only
|
|
18
|
-
* cosmetically.
|
|
15
|
+
* don't want to cascade-async every caller in the codebase. `@noble/ed25519`'s
|
|
16
|
+
* `verify` is itself synchronous (backed by a synchronous SHA-512 hook).
|
|
19
17
|
*
|
|
20
18
|
* Verification proceeds in this order:
|
|
21
19
|
* 1. Recompute the canonical share-data string + hash, folding in
|
|
@@ -36,5 +34,5 @@ import { ShareData } from '../../share-data';
|
|
|
36
34
|
* `(hash, previousHash, timestamp)` triple, not that the hash matches
|
|
37
35
|
* anything real.
|
|
38
36
|
*/
|
|
39
|
-
export declare const verifyShareDataProposalProof: (proof: IShareDataCryptoProof, shareData: ShareData
|
|
37
|
+
export declare const verifyShareDataProposalProof: (proof: IShareDataCryptoProof, shareData: ShareData) => true;
|
|
40
38
|
//# sourceMappingURL=verify-share-data-proposal-proof.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-share-data-proposal-proof.d.ts","sourceRoot":"","sources":["../../../../src/share-data/proofs/verification/verify-share-data-proposal-proof.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verify-share-data-proposal-proof.d.ts","sourceRoot":"","sources":["../../../../src/share-data/proofs/verification/verify-share-data-proposal-proof.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,qBAAqB,EAGxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAI7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,eAAO,MAAM,4BAA4B,GACrC,OAAO,qBAAqB,EAC5B,WAAW,SAAS,KACrB,IAwCF,CAAC"}
|
|
@@ -1,40 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.verifyShareDataProposalProof = void 0;
|
|
37
|
-
const elliptic = __importStar(require("elliptic"));
|
|
38
4
|
const generic_1 = require("@degenerate/generic");
|
|
39
5
|
const calculate_share_data_string_1 = require("../../helpers/calculate-share-data-string");
|
|
40
6
|
const get_previous_hash_from_share_data_1 = require("../helpers/get-previous-hash-from-share-data");
|
|
@@ -51,10 +17,8 @@ const create_share_data_string_to_sign_1 = require("../helpers/create-share-data
|
|
|
51
17
|
* requires the private key).
|
|
52
18
|
*
|
|
53
19
|
* Synchronous on purpose — `addFunction` / `addRule` are synchronous and we
|
|
54
|
-
* don't want to cascade-async every caller in the codebase.
|
|
55
|
-
* `
|
|
56
|
-
* project's existing `verifyCryptoSignatureByHash` wrapper is `async` only
|
|
57
|
-
* cosmetically.
|
|
20
|
+
* don't want to cascade-async every caller in the codebase. `@noble/ed25519`'s
|
|
21
|
+
* `verify` is itself synchronous (backed by a synchronous SHA-512 hook).
|
|
58
22
|
*
|
|
59
23
|
* Verification proceeds in this order:
|
|
60
24
|
* 1. Recompute the canonical share-data string + hash, folding in
|
|
@@ -75,7 +39,7 @@ const create_share_data_string_to_sign_1 = require("../helpers/create-share-data
|
|
|
75
39
|
* `(hash, previousHash, timestamp)` triple, not that the hash matches
|
|
76
40
|
* anything real.
|
|
77
41
|
*/
|
|
78
|
-
const verifyShareDataProposalProof = (proof, shareData
|
|
42
|
+
const verifyShareDataProposalProof = (proof, shareData) => {
|
|
79
43
|
// Step 1: hash of current state matches what the proof claims. The
|
|
80
44
|
// purpose comes from the proof itself, so a tampered purpose produces
|
|
81
45
|
// a different hash and gets caught here.
|
|
@@ -101,24 +65,11 @@ const verifyShareDataProposalProof = (proof, shareData, ellipticalCurve = generi
|
|
|
101
65
|
// Step 3: signature verifies against the proof's publicKey for the
|
|
102
66
|
// (now-validated) hash + previousHash + timestamp triple.
|
|
103
67
|
const signedString = (0, create_share_data_string_to_sign_1.createShareDataStringToSign)(proof.shareDataHash, proof.shareDataPreviousHash, proof.timestamp);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
// so the verifier sees the same fixed-size 256-bit digest the signer
|
|
110
|
-
// operated on. Without this, elliptic's ECDSA on ed25519 silently
|
|
111
|
-
// truncates inputs longer than ~253 bits and the signature stops
|
|
112
|
-
// binding the trailing bytes (timestamp, tail of previousHash).
|
|
113
|
-
const digest = (0, generic_1.calculateHash)(signedString);
|
|
114
|
-
signatureValid = key.verify(digest, proof.shareDataSignature);
|
|
115
|
-
}
|
|
116
|
-
catch {
|
|
117
|
-
// elliptic throws on malformed signature/key strings rather than
|
|
118
|
-
// returning false — normalize to a single rejection mode.
|
|
119
|
-
throw new generic_1.ShareDataStructuralProofFailedError(shareData.id);
|
|
120
|
-
}
|
|
121
|
-
if (!signatureValid) {
|
|
68
|
+
// EdDSA signs the message bytes directly (Ed25519 hashes internally with
|
|
69
|
+
// SHA-512), so no SHA-256 pre-hash here — the signer didn't pre-hash either.
|
|
70
|
+
// `verifyEd25519Signature` already normalizes malformed key/signature hex
|
|
71
|
+
// to a `false` return rather than throwing.
|
|
72
|
+
if (!(0, generic_1.verifyEd25519Signature)(proof.publicKey, signedString, proof.shareDataSignature)) {
|
|
122
73
|
throw new generic_1.ShareDataStructuralProofFailedError(shareData.id);
|
|
123
74
|
}
|
|
124
75
|
return true;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IShareData, IShareDataCryptoProof } from '@degenerate/generic';
|
|
2
2
|
import { ShareData } from '../../share-data';
|
|
3
3
|
/**
|
|
4
4
|
* Verify a transaction proposal proof against the live `shareData` and the
|
|
@@ -30,8 +30,8 @@ import { ShareData } from '../../share-data';
|
|
|
30
30
|
* hash, a structural proof's signature can never satisfy this check — the two
|
|
31
31
|
* proof kinds are non-interchangeable.
|
|
32
32
|
*
|
|
33
|
-
* Synchronous to match the rest of the proof pipeline;
|
|
34
|
-
* is itself synchronous.
|
|
33
|
+
* Synchronous to match the rest of the proof pipeline; `@noble/ed25519`'s
|
|
34
|
+
* `verify` is itself synchronous.
|
|
35
35
|
*/
|
|
36
|
-
export declare const verifyTransactionProposalProof: (proof: IShareDataCryptoProof, shareData: ShareData, proposedState: IShareData
|
|
36
|
+
export declare const verifyTransactionProposalProof: (proof: IShareDataCryptoProof, shareData: ShareData, proposedState: IShareData) => true;
|
|
37
37
|
//# sourceMappingURL=verify-transaction-proposal-proof.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-transaction-proposal-proof.d.ts","sourceRoot":"","sources":["../../../../src/share-data/proofs/verification/verify-transaction-proposal-proof.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"verify-transaction-proposal-proof.d.ts","sourceRoot":"","sources":["../../../../src/share-data/proofs/verification/verify-transaction-proposal-proof.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,UAAU,EACV,qBAAqB,EAGxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAK7C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,eAAO,MAAM,8BAA8B,GACvC,OAAO,qBAAqB,EAC5B,WAAW,SAAS,EACpB,eAAe,UAAU,KAC1B,IA6CF,CAAC"}
|
|
@@ -1,40 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
3
|
exports.verifyTransactionProposalProof = void 0;
|
|
37
|
-
const elliptic = __importStar(require("elliptic"));
|
|
38
4
|
const generic_1 = require("@degenerate/generic");
|
|
39
5
|
const calculate_share_data_string_1 = require("../../helpers/calculate-share-data-string");
|
|
40
6
|
const get_previous_hash_from_share_data_1 = require("../helpers/get-previous-hash-from-share-data");
|
|
@@ -70,10 +36,10 @@ const hash_proposed_state_1 = require("../helpers/hash-proposed-state");
|
|
|
70
36
|
* hash, a structural proof's signature can never satisfy this check — the two
|
|
71
37
|
* proof kinds are non-interchangeable.
|
|
72
38
|
*
|
|
73
|
-
* Synchronous to match the rest of the proof pipeline;
|
|
74
|
-
* is itself synchronous.
|
|
39
|
+
* Synchronous to match the rest of the proof pipeline; `@noble/ed25519`'s
|
|
40
|
+
* `verify` is itself synchronous.
|
|
75
41
|
*/
|
|
76
|
-
const verifyTransactionProposalProof = (proof, shareData, proposedState
|
|
42
|
+
const verifyTransactionProposalProof = (proof, shareData, proposedState) => {
|
|
77
43
|
// Step 1: current-state hash matches what the proof claims. The purpose
|
|
78
44
|
// (functionId) comes from the proof itself, so a tampered purpose
|
|
79
45
|
// produces a different hash and is caught here.
|
|
@@ -101,23 +67,11 @@ const verifyTransactionProposalProof = (proof, shareData, proposedState, ellipti
|
|
|
101
67
|
// Step 4: signature verifies over the full transaction payload (which
|
|
102
68
|
// includes the proposed-state hash and the `tx:` discriminator).
|
|
103
69
|
const signedString = (0, create_transaction_proposal_string_to_sign_1.createTransactionProposalStringToSign)(proof.shareDataHash, proposedStateHash, proof.purpose, proof.shareDataPreviousHash, proof.timestamp);
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
// so the verifier operates on the same fixed-size digest the signer
|
|
110
|
-
// did. Without this, elliptic's ECDSA on ed25519 silently truncates
|
|
111
|
-
// long inputs and stops binding the trailing bytes.
|
|
112
|
-
const digest = (0, generic_1.calculateHash)(signedString);
|
|
113
|
-
signatureValid = key.verify(digest, proof.shareDataSignature);
|
|
114
|
-
}
|
|
115
|
-
catch {
|
|
116
|
-
// elliptic throws on malformed signature/key strings rather than
|
|
117
|
-
// returning false — normalize to a single rejection mode.
|
|
118
|
-
throw new generic_1.ShareDataTransactionProofFailedError(shareData.id);
|
|
119
|
-
}
|
|
120
|
-
if (!signatureValid) {
|
|
70
|
+
// EdDSA signs the message bytes directly (Ed25519 hashes internally with
|
|
71
|
+
// SHA-512), so no SHA-256 pre-hash here — the signer didn't pre-hash either.
|
|
72
|
+
// `verifyEd25519Signature` already normalizes malformed key/signature hex
|
|
73
|
+
// to a `false` return rather than throwing.
|
|
74
|
+
if (!(0, generic_1.verifyEd25519Signature)(proof.publicKey, signedString, proof.shareDataSignature)) {
|
|
121
75
|
throw new generic_1.ShareDataTransactionProofFailedError(shareData.id);
|
|
122
76
|
}
|
|
123
77
|
return true;
|
|
@@ -258,7 +258,7 @@ export declare class ShareData {
|
|
|
258
258
|
* success; throws `ShareDataStructuralProofFailedError` on any mismatch
|
|
259
259
|
* (hash, previousHash, signature, or purpose).
|
|
260
260
|
*/
|
|
261
|
-
verifyStructuralProof(proof: IShareDataCryptoProof
|
|
261
|
+
verifyStructuralProof(proof: IShareDataCryptoProof): true;
|
|
262
262
|
/**
|
|
263
263
|
* Verifies that `proof` authorizes applying a transaction that moves this
|
|
264
264
|
* share-data to exactly `proposedData`. Unlike {@link verifyStructuralProof}
|
|
@@ -267,7 +267,7 @@ export declare class ShareData {
|
|
|
267
267
|
* verify against any other. Returns `true`; throws
|
|
268
268
|
* `ShareDataTransactionProofFailedError` on any mismatch.
|
|
269
269
|
*/
|
|
270
|
-
verifyTransactionProof(proof: IShareDataCryptoProof, proposedData: IShareData
|
|
270
|
+
verifyTransactionProof(proof: IShareDataCryptoProof, proposedData: IShareData): true;
|
|
271
271
|
/**
|
|
272
272
|
* This adds a structure proof to the share data
|
|
273
273
|
* @param proof the structure proof to add
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"share-data.d.ts","sourceRoot":"","sources":["../../src/share-data/share-data.ts"],"names":[],"mappings":"AACA,OAAO,EACH,UAAU,EACV,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,yBAAyB,EACzB,4BAA4B,EAG5B,qBAAqB,EAErB,uBAAuB,EACvB,2BAA2B,EAK3B,iBAAiB,EAGpB,MAAM,qBAAqB,CAAC;AAI7B;;GAEG;AACH,qBAAa,SAAS;IAClB,OAAO,CAAC,GAAG,CAAS;IACpB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,SAAS,CAAU;IAC3B,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,UAAU,CAAsD;IACxE,OAAO,CAAC,mBAAmB,CAAiC;IAC5D,OAAO,CAAC,OAAO,CAAoB;IAEnC,OAAO,CAAC,aAAa,CAAa;IAClC,OAAO,CAAC,aAAa,CAA0B;IAC/C,OAAO,CAAC,kBAAkB,CAAS;IACnC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,kBAAkB,CAAS;IACn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,GAC7B;QAAE,QAAQ,EAAE,OAAO,CAAC;QAAC,aAAa,EAAE,MAAM,CAAA;KAAE;IAgC/C;;;;;OAKG;IACH,OAAO,CAAC,gBAAgB;IAgCxB;;;;OAIG;IACH,MAAM,CAAC,iBAAiB,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS;IAgB/D;;;OAGG;IACH,cAAc,CAAC,KAAK,EAAE,qBAAqB,GAAG,IAAI;IAIlD;;;;;OAKG;IACH,qBAAqB,CACjB,KAAK,EAAE,qBAAqB,GAC7B,IAAI;IAIP;;;;;;;OAOG;IACH,sBAAsB,CAClB,KAAK,EAAE,qBAAqB,EAC5B,YAAY,EAAE,UAAU,GACzB,IAAI;IAQP;;;OAGG;IACH,kBAAkB,CAAC,KAAK,EAAE,qBAAqB,GAAG,IAAI;IAUtD;;OAEG;IACH,UAAU,IAAI,IAAI;CAQrB"}
|
|
@@ -448,8 +448,8 @@ class ShareData {
|
|
|
448
448
|
* success; throws `ShareDataStructuralProofFailedError` on any mismatch
|
|
449
449
|
* (hash, previousHash, signature, or purpose).
|
|
450
450
|
*/
|
|
451
|
-
verifyStructuralProof(proof
|
|
452
|
-
return (0, verify_share_data_proposal_proof_1.verifyShareDataProposalProof)(proof, this
|
|
451
|
+
verifyStructuralProof(proof) {
|
|
452
|
+
return (0, verify_share_data_proposal_proof_1.verifyShareDataProposalProof)(proof, this);
|
|
453
453
|
}
|
|
454
454
|
/**
|
|
455
455
|
* Verifies that `proof` authorizes applying a transaction that moves this
|
|
@@ -459,8 +459,8 @@ class ShareData {
|
|
|
459
459
|
* verify against any other. Returns `true`; throws
|
|
460
460
|
* `ShareDataTransactionProofFailedError` on any mismatch.
|
|
461
461
|
*/
|
|
462
|
-
verifyTransactionProof(proof, proposedData
|
|
463
|
-
return (0, verify_transaction_proposal_proof_1.verifyTransactionProposalProof)(proof, this, proposedData
|
|
462
|
+
verifyTransactionProof(proof, proposedData) {
|
|
463
|
+
return (0, verify_transaction_proposal_proof_1.verifyTransactionProposalProof)(proof, this, proposedData);
|
|
464
464
|
}
|
|
465
465
|
//#endregion Crypto Proofs
|
|
466
466
|
//#region Structure Proofs
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@degenerate/sharedata",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "This contains the ShareData Adaptive Framework Ecosystem (SAFE) network core code",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -49,10 +49,10 @@
|
|
|
49
49
|
"url": "https://github.com/syncrude/safe/issues"
|
|
50
50
|
},
|
|
51
51
|
"homepage": "https://github.com/syncrude/safe#readme",
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "c8c1a2f456cdb01a74f85779275b246361e33b81",
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@degenerate/generic": "^0.
|
|
55
|
-
"@degenerate/rules": "^0.
|
|
54
|
+
"@degenerate/generic": "^0.6.0",
|
|
55
|
+
"@degenerate/rules": "^0.6.0",
|
|
56
56
|
"zod": "^4.4.3"
|
|
57
57
|
},
|
|
58
58
|
"engines": {
|