@taquito/sapling 17.3.2 → 17.4.0-beta-RC.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/lib/constants.js +0 -1
- package/dist/lib/errors.js +0 -1
- package/dist/lib/sapling-forger/sapling-forger.js +8 -9
- package/dist/lib/sapling-keys/helpers.js +6 -7
- package/dist/lib/sapling-keys/in-memory-proving-key.js +15 -18
- package/dist/lib/sapling-keys/in-memory-spending-key.js +22 -25
- package/dist/lib/sapling-keys/in-memory-viewing-key.js +18 -21
- package/dist/lib/sapling-module-wrapper.js +1 -2
- package/dist/lib/sapling-state/sapling-state.js +6 -7
- package/dist/lib/sapling-state/utils.js +0 -1
- package/dist/lib/sapling-tx-builder/sapling-transactions-builder.js +78 -80
- package/dist/lib/sapling-tx-viewer/helpers.js +2 -3
- package/dist/lib/sapling-tx-viewer/sapling-transaction-viewer.js +36 -39
- package/dist/lib/taquito-sapling.js +55 -58
- package/dist/lib/types.js +0 -1
- package/dist/lib/version.js +2 -3
- package/dist/taquito-sapling.es6.js +1383 -1380
- package/dist/taquito-sapling.es6.js.map +1 -1
- package/dist/taquito-sapling.umd.js +1387 -1393
- package/dist/taquito-sapling.umd.js.map +1 -1
- package/dist/types/constants.d.ts +5 -5
- package/dist/types/errors.d.ts +52 -52
- package/dist/types/sapling-forger/sapling-forger.d.ts +30 -30
- package/dist/types/sapling-keys/helpers.d.ts +2 -2
- package/dist/types/sapling-keys/in-memory-proving-key.d.ts +35 -35
- package/dist/types/sapling-keys/in-memory-spending-key.d.ts +53 -53
- package/dist/types/sapling-keys/in-memory-viewing-key.d.ts +48 -48
- package/dist/types/sapling-module-wrapper.d.ts +19 -19
- package/dist/types/sapling-state/sapling-state.d.ts +56 -56
- package/dist/types/sapling-state/utils.d.ts +22 -22
- package/dist/types/sapling-tx-builder/sapling-transactions-builder.d.ts +32 -32
- package/dist/types/sapling-tx-viewer/helpers.d.ts +11 -11
- package/dist/types/sapling-tx-viewer/sapling-transaction-viewer.d.ts +50 -50
- package/dist/types/taquito-sapling.d.ts +81 -81
- package/dist/types/types.d.ts +147 -147
- package/dist/types/version.d.ts +4 -4
- package/package.json +33 -35
- package/dist/lib/constants.js.map +0 -1
- package/dist/lib/errors.js.map +0 -1
- package/dist/lib/sapling-forger/sapling-forger.js.map +0 -1
- package/dist/lib/sapling-keys/helpers.js.map +0 -1
- package/dist/lib/sapling-keys/in-memory-proving-key.js.map +0 -1
- package/dist/lib/sapling-keys/in-memory-spending-key.js.map +0 -1
- package/dist/lib/sapling-keys/in-memory-viewing-key.js.map +0 -1
- package/dist/lib/sapling-module-wrapper.js.map +0 -1
- package/dist/lib/sapling-state/sapling-state.js.map +0 -1
- package/dist/lib/sapling-state/utils.js.map +0 -1
- package/dist/lib/sapling-tx-builder/sapling-transactions-builder.js.map +0 -1
- package/dist/lib/sapling-tx-viewer/helpers.js.map +0 -1
- package/dist/lib/sapling-tx-viewer/sapling-transaction-viewer.js.map +0 -1
- package/dist/lib/taquito-sapling.js.map +0 -1
- package/dist/lib/types.js.map +0 -1
- package/dist/lib/version.js.map +0 -1
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import { InMemoryViewingKey } from './in-memory-viewing-key';
|
|
2
|
-
import { ParametersSpendProof, ParametersSpendSig, SaplingSpendDescription, SaplingTransactionInput } from '../types';
|
|
3
|
-
/**
|
|
4
|
-
* @description holds the spending key, create proof and signature for spend descriptions
|
|
5
|
-
* can instantiate from mnemonic word list or decrypt a encrypted spending key
|
|
6
|
-
* with access to instantiate a InMemoryViewingKey
|
|
7
|
-
*/
|
|
8
|
-
export declare class InMemorySpendingKey {
|
|
9
|
-
#private;
|
|
10
|
-
/**
|
|
11
|
-
*
|
|
12
|
-
* @param spendingKey unencrypted sask... or encrypted MMXj...
|
|
13
|
-
* @param password required for MMXj encrypted keys
|
|
14
|
-
*/
|
|
15
|
-
constructor(spendingKey: string, password?: string);
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
* @param mnemonic string of words
|
|
19
|
-
* @param derivationPath tezos current standard 'm/'
|
|
20
|
-
* @returns InMemorySpendingKey class instantiated
|
|
21
|
-
*/
|
|
22
|
-
static fromMnemonic(mnemonic: string, derivationPath?: string): Promise<InMemorySpendingKey>;
|
|
23
|
-
/**
|
|
24
|
-
*
|
|
25
|
-
* @returns InMemoryViewingKey instantiated class
|
|
26
|
-
*/
|
|
27
|
-
getSaplingViewingKeyProvider(): Promise<InMemoryViewingKey>;
|
|
28
|
-
/**
|
|
29
|
-
* @description Prepare an unsigned sapling spend description using the spending key
|
|
30
|
-
* @param parametersSpendProof.saplingContext The sapling proving context
|
|
31
|
-
* @param parametersSpendProof.address The address of the input
|
|
32
|
-
* @param parametersSpendProof.randomCommitmentTrapdoor The randomness of the commitment
|
|
33
|
-
* @param parametersSpendProof.publicKeyReRandomization The re-randomization of the public key
|
|
34
|
-
* @param parametersSpendProof.amount The value of the input
|
|
35
|
-
* @param parametersSpendProof.root The root of the merkle tree
|
|
36
|
-
* @param parametersSpendProof.witness The path of the commitment in the tree
|
|
37
|
-
* @param derivationPath tezos current standard 'm/'
|
|
38
|
-
* @returns The unsigned spend description
|
|
39
|
-
*/
|
|
40
|
-
prepareSpendDescription(parametersSpendProof: ParametersSpendProof): Promise<Omit<SaplingSpendDescription, 'signature'>>;
|
|
41
|
-
/**
|
|
42
|
-
* @description Sign a sapling spend description
|
|
43
|
-
* @param parametersSpendSig.publicKeyReRandomization The re-randomization of the public key
|
|
44
|
-
* @param parametersSpendSig.unsignedSpendDescription The unsigned Spend description
|
|
45
|
-
* @param parametersSpendSig.hash The data to be signed
|
|
46
|
-
* @returns The signed spend description
|
|
47
|
-
*/
|
|
48
|
-
signSpendDescription(parametersSpendSig: ParametersSpendSig): Promise<SaplingTransactionInput>;
|
|
49
|
-
/**
|
|
50
|
-
* @description Return a proof authorizing key from the configured spending key
|
|
51
|
-
*/
|
|
52
|
-
getProvingKey(): Promise<string>;
|
|
53
|
-
}
|
|
1
|
+
import { InMemoryViewingKey } from './in-memory-viewing-key';
|
|
2
|
+
import { ParametersSpendProof, ParametersSpendSig, SaplingSpendDescription, SaplingTransactionInput } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* @description holds the spending key, create proof and signature for spend descriptions
|
|
5
|
+
* can instantiate from mnemonic word list or decrypt a encrypted spending key
|
|
6
|
+
* with access to instantiate a InMemoryViewingKey
|
|
7
|
+
*/
|
|
8
|
+
export declare class InMemorySpendingKey {
|
|
9
|
+
#private;
|
|
10
|
+
/**
|
|
11
|
+
*
|
|
12
|
+
* @param spendingKey unencrypted sask... or encrypted MMXj...
|
|
13
|
+
* @param password required for MMXj encrypted keys
|
|
14
|
+
*/
|
|
15
|
+
constructor(spendingKey: string, password?: string);
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param mnemonic string of words
|
|
19
|
+
* @param derivationPath tezos current standard 'm/'
|
|
20
|
+
* @returns InMemorySpendingKey class instantiated
|
|
21
|
+
*/
|
|
22
|
+
static fromMnemonic(mnemonic: string, derivationPath?: string): Promise<InMemorySpendingKey>;
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @returns InMemoryViewingKey instantiated class
|
|
26
|
+
*/
|
|
27
|
+
getSaplingViewingKeyProvider(): Promise<InMemoryViewingKey>;
|
|
28
|
+
/**
|
|
29
|
+
* @description Prepare an unsigned sapling spend description using the spending key
|
|
30
|
+
* @param parametersSpendProof.saplingContext The sapling proving context
|
|
31
|
+
* @param parametersSpendProof.address The address of the input
|
|
32
|
+
* @param parametersSpendProof.randomCommitmentTrapdoor The randomness of the commitment
|
|
33
|
+
* @param parametersSpendProof.publicKeyReRandomization The re-randomization of the public key
|
|
34
|
+
* @param parametersSpendProof.amount The value of the input
|
|
35
|
+
* @param parametersSpendProof.root The root of the merkle tree
|
|
36
|
+
* @param parametersSpendProof.witness The path of the commitment in the tree
|
|
37
|
+
* @param derivationPath tezos current standard 'm/'
|
|
38
|
+
* @returns The unsigned spend description
|
|
39
|
+
*/
|
|
40
|
+
prepareSpendDescription(parametersSpendProof: ParametersSpendProof): Promise<Omit<SaplingSpendDescription, 'signature'>>;
|
|
41
|
+
/**
|
|
42
|
+
* @description Sign a sapling spend description
|
|
43
|
+
* @param parametersSpendSig.publicKeyReRandomization The re-randomization of the public key
|
|
44
|
+
* @param parametersSpendSig.unsignedSpendDescription The unsigned Spend description
|
|
45
|
+
* @param parametersSpendSig.hash The data to be signed
|
|
46
|
+
* @returns The signed spend description
|
|
47
|
+
*/
|
|
48
|
+
signSpendDescription(parametersSpendSig: ParametersSpendSig): Promise<SaplingTransactionInput>;
|
|
49
|
+
/**
|
|
50
|
+
* @description Return a proof authorizing key from the configured spending key
|
|
51
|
+
*/
|
|
52
|
+
getProvingKey(): Promise<string>;
|
|
53
|
+
}
|
|
@@ -1,48 +1,48 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
/**
|
|
3
|
-
* @description Holds the viewing key
|
|
4
|
-
*/
|
|
5
|
-
export declare class InMemoryViewingKey {
|
|
6
|
-
#private;
|
|
7
|
-
constructor(fullViewingKey: string);
|
|
8
|
-
/**
|
|
9
|
-
* @description Allows to instantiate the InMemoryViewingKey from an encrypted/unencrypted spending key
|
|
10
|
-
*
|
|
11
|
-
* @param spendingKey Base58Check-encoded spending key
|
|
12
|
-
* @param password Optional password to decrypt the spending key
|
|
13
|
-
* @example
|
|
14
|
-
* ```
|
|
15
|
-
* await InMemoryViewingKey.fromSpendingKey('sask27SLmU9herddHz4qFJBLMjWYMbJF8RtS579w9ej9mfCYK7VUdyCJPHK8AzW9zMsopGZEkYeNjAY7Zz1bkM7CGu8eKLzrjBLTMC5wWJDhxiK91ahA29rhDRsHdJDV2u2jFwb2MNUix8JW7sAkAqYVaJpCehTBPgRQ1KqKwqqUaNmuD8kazd4Q8MCWmgbWs21Yuomdqyi9FLigjRp7oY4m5adaVU19Nj1AHvsMY2tePeU2L')
|
|
16
|
-
* ```
|
|
17
|
-
*
|
|
18
|
-
*/
|
|
19
|
-
static fromSpendingKey(spendingKey: string, password?: string): Promise<InMemoryViewingKey>;
|
|
20
|
-
/**
|
|
21
|
-
* @description Retrieve the full viewing key
|
|
22
|
-
* @returns Buffer representing the full viewing key
|
|
23
|
-
*
|
|
24
|
-
*/
|
|
25
|
-
getFullViewingKey(): Buffer;
|
|
26
|
-
/**
|
|
27
|
-
* @description Retrieve the outgoing viewing key
|
|
28
|
-
* @returns Buffer representing the outgoing viewing key
|
|
29
|
-
*
|
|
30
|
-
*/
|
|
31
|
-
getOutgoingViewingKey(): Promise<Buffer>;
|
|
32
|
-
/**
|
|
33
|
-
* @description Retrieve the incoming viewing key
|
|
34
|
-
* @returns Buffer representing the incoming viewing key
|
|
35
|
-
*
|
|
36
|
-
*/
|
|
37
|
-
getIncomingViewingKey(): Promise<Buffer>;
|
|
38
|
-
/**
|
|
39
|
-
* @description Retrieve a payment address
|
|
40
|
-
* @param addressIndex used to determine which diversifier should be used to derive the address, default is 0
|
|
41
|
-
* @returns Base58Check-encoded address and its index
|
|
42
|
-
*
|
|
43
|
-
*/
|
|
44
|
-
getAddress(addressIndex?: number): Promise<{
|
|
45
|
-
address: string;
|
|
46
|
-
addressIndex: number;
|
|
47
|
-
}>;
|
|
48
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/**
|
|
3
|
+
* @description Holds the viewing key
|
|
4
|
+
*/
|
|
5
|
+
export declare class InMemoryViewingKey {
|
|
6
|
+
#private;
|
|
7
|
+
constructor(fullViewingKey: string);
|
|
8
|
+
/**
|
|
9
|
+
* @description Allows to instantiate the InMemoryViewingKey from an encrypted/unencrypted spending key
|
|
10
|
+
*
|
|
11
|
+
* @param spendingKey Base58Check-encoded spending key
|
|
12
|
+
* @param password Optional password to decrypt the spending key
|
|
13
|
+
* @example
|
|
14
|
+
* ```
|
|
15
|
+
* await InMemoryViewingKey.fromSpendingKey('sask27SLmU9herddHz4qFJBLMjWYMbJF8RtS579w9ej9mfCYK7VUdyCJPHK8AzW9zMsopGZEkYeNjAY7Zz1bkM7CGu8eKLzrjBLTMC5wWJDhxiK91ahA29rhDRsHdJDV2u2jFwb2MNUix8JW7sAkAqYVaJpCehTBPgRQ1KqKwqqUaNmuD8kazd4Q8MCWmgbWs21Yuomdqyi9FLigjRp7oY4m5adaVU19Nj1AHvsMY2tePeU2L')
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
static fromSpendingKey(spendingKey: string, password?: string): Promise<InMemoryViewingKey>;
|
|
20
|
+
/**
|
|
21
|
+
* @description Retrieve the full viewing key
|
|
22
|
+
* @returns Buffer representing the full viewing key
|
|
23
|
+
*
|
|
24
|
+
*/
|
|
25
|
+
getFullViewingKey(): Buffer;
|
|
26
|
+
/**
|
|
27
|
+
* @description Retrieve the outgoing viewing key
|
|
28
|
+
* @returns Buffer representing the outgoing viewing key
|
|
29
|
+
*
|
|
30
|
+
*/
|
|
31
|
+
getOutgoingViewingKey(): Promise<Buffer>;
|
|
32
|
+
/**
|
|
33
|
+
* @description Retrieve the incoming viewing key
|
|
34
|
+
* @returns Buffer representing the incoming viewing key
|
|
35
|
+
*
|
|
36
|
+
*/
|
|
37
|
+
getIncomingViewingKey(): Promise<Buffer>;
|
|
38
|
+
/**
|
|
39
|
+
* @description Retrieve a payment address
|
|
40
|
+
* @param addressIndex used to determine which diversifier should be used to derive the address, default is 0
|
|
41
|
+
* @returns Base58Check-encoded address and its index
|
|
42
|
+
*
|
|
43
|
+
*/
|
|
44
|
+
getAddress(addressIndex?: number): Promise<{
|
|
45
|
+
address: string;
|
|
46
|
+
addressIndex: number;
|
|
47
|
+
}>;
|
|
48
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { ParametersOutputProof } from './types';
|
|
3
|
-
export declare class SaplingWrapper {
|
|
4
|
-
withProvingContext<T>(action: (context: number) => Promise<T>): Promise<T>;
|
|
5
|
-
getRandomBytes(length: number): Uint8Array;
|
|
6
|
-
randR(): Promise<Buffer>;
|
|
7
|
-
getOutgoingViewingKey(vk: Buffer): Promise<Buffer>;
|
|
8
|
-
preparePartialOutputDescription(parametersOutputProof: ParametersOutputProof): Promise<{
|
|
9
|
-
commitmentValue: Buffer;
|
|
10
|
-
commitment: Buffer;
|
|
11
|
-
proof: Buffer;
|
|
12
|
-
}>;
|
|
13
|
-
getDiversifiedFromRawPaymentAddress(decodedDestination: Uint8Array): Promise<Buffer>;
|
|
14
|
-
deriveEphemeralPublicKey(diversifier: Buffer, esk: Buffer): Promise<Buffer>;
|
|
15
|
-
getPkdFromRawPaymentAddress(destination: Uint8Array): Promise<Buffer>;
|
|
16
|
-
keyAgreement(p: Buffer, sk: Buffer): Promise<Buffer>;
|
|
17
|
-
createBindingSignature(saplingContext: number, balance: string, transactionSigHash: Uint8Array): Promise<Buffer>;
|
|
18
|
-
initSaplingParameters(): Promise<void>;
|
|
19
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ParametersOutputProof } from './types';
|
|
3
|
+
export declare class SaplingWrapper {
|
|
4
|
+
withProvingContext<T>(action: (context: number) => Promise<T>): Promise<T>;
|
|
5
|
+
getRandomBytes(length: number): Uint8Array;
|
|
6
|
+
randR(): Promise<Buffer>;
|
|
7
|
+
getOutgoingViewingKey(vk: Buffer): Promise<Buffer>;
|
|
8
|
+
preparePartialOutputDescription(parametersOutputProof: ParametersOutputProof): Promise<{
|
|
9
|
+
commitmentValue: Buffer;
|
|
10
|
+
commitment: Buffer;
|
|
11
|
+
proof: Buffer;
|
|
12
|
+
}>;
|
|
13
|
+
getDiversifiedFromRawPaymentAddress(decodedDestination: Uint8Array): Promise<Buffer>;
|
|
14
|
+
deriveEphemeralPublicKey(diversifier: Buffer, esk: Buffer): Promise<Buffer>;
|
|
15
|
+
getPkdFromRawPaymentAddress(destination: Uint8Array): Promise<Buffer>;
|
|
16
|
+
keyAgreement(p: Buffer, sk: Buffer): Promise<Buffer>;
|
|
17
|
+
createBindingSignature(saplingContext: number, balance: string, transactionSigHash: Uint8Array): Promise<Buffer>;
|
|
18
|
+
initSaplingParameters(): Promise<void>;
|
|
19
|
+
}
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Some code in this file was originally written or inspired by Airgap-it
|
|
3
|
-
* https://github.com/airgap-it/airgap-coin-lib/blob/master/LICENSE.md
|
|
4
|
-
*
|
|
5
|
-
*/
|
|
6
|
-
import { SaplingDiffResponse } from '@taquito/rpc';
|
|
7
|
-
import BigNumber from 'bignumber.js';
|
|
8
|
-
import { SaplingStateTree } from '../types';
|
|
9
|
-
/**
|
|
10
|
-
* @description The SaplingState class's main purpose is to provide a Merkle path for the forger and the transaction builder, so that it may verify that the Sapling transaction is valid
|
|
11
|
-
*
|
|
12
|
-
*/
|
|
13
|
-
export declare class SaplingState {
|
|
14
|
-
readonly height: number;
|
|
15
|
-
private stateTree;
|
|
16
|
-
private readonly uncommittedMerkleHash;
|
|
17
|
-
private readonly uncommittedMerkleHashes;
|
|
18
|
-
constructor(height: number);
|
|
19
|
-
getStateTree(stateDiff: SaplingDiffResponse, constructTree?: boolean): Promise<SaplingStateTree>;
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* @param stateTree stateTree parameter that holds information details on our Merkle tree
|
|
23
|
-
* @param position position of the hash in the Merkle tree
|
|
24
|
-
* @returns a promise of a string that serves as the Merkle path that can be passed on to the Sapling forger or the transaction builder
|
|
25
|
-
*/
|
|
26
|
-
getWitness(stateTree: SaplingStateTree, position: BigNumber): Promise<string>;
|
|
27
|
-
/**
|
|
28
|
-
*
|
|
29
|
-
* @param leaves array of leaves or nodes that we want to construct the Merkle tree from
|
|
30
|
-
* @param height height of the desired Merkle tree
|
|
31
|
-
* @returns a promise of MerkleTree type object
|
|
32
|
-
*/
|
|
33
|
-
private constructMerkleTree;
|
|
34
|
-
private getMerkleHash;
|
|
35
|
-
/**
|
|
36
|
-
*
|
|
37
|
-
* @returns hashes of empty or null values to fill in the Merkle tree
|
|
38
|
-
*/
|
|
39
|
-
private createUncommittedMerkleHashes;
|
|
40
|
-
/**
|
|
41
|
-
*
|
|
42
|
-
* @param tree Merkle tree to validate
|
|
43
|
-
* @param expectedRoot the expected merkle root to validate against
|
|
44
|
-
* @throws {@link InvalidMerkleTreeError}
|
|
45
|
-
*/
|
|
46
|
-
private validateMerkleTree;
|
|
47
|
-
/**
|
|
48
|
-
*
|
|
49
|
-
* @param acc accumulator variable for the recursive function
|
|
50
|
-
* @param height height of the tree
|
|
51
|
-
* @param position position of the hash we would like find the neighbours of
|
|
52
|
-
* @param tree the Merkle tree that we want to traverse
|
|
53
|
-
* @returns the accumulated Buffer array of neighbouring hashes
|
|
54
|
-
*/
|
|
55
|
-
private getNeighbouringHashes;
|
|
56
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Some code in this file was originally written or inspired by Airgap-it
|
|
3
|
+
* https://github.com/airgap-it/airgap-coin-lib/blob/master/LICENSE.md
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
import { SaplingDiffResponse } from '@taquito/rpc';
|
|
7
|
+
import BigNumber from 'bignumber.js';
|
|
8
|
+
import { SaplingStateTree } from '../types';
|
|
9
|
+
/**
|
|
10
|
+
* @description The SaplingState class's main purpose is to provide a Merkle path for the forger and the transaction builder, so that it may verify that the Sapling transaction is valid
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
export declare class SaplingState {
|
|
14
|
+
readonly height: number;
|
|
15
|
+
private stateTree;
|
|
16
|
+
private readonly uncommittedMerkleHash;
|
|
17
|
+
private readonly uncommittedMerkleHashes;
|
|
18
|
+
constructor(height: number);
|
|
19
|
+
getStateTree(stateDiff: SaplingDiffResponse, constructTree?: boolean): Promise<SaplingStateTree>;
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param stateTree stateTree parameter that holds information details on our Merkle tree
|
|
23
|
+
* @param position position of the hash in the Merkle tree
|
|
24
|
+
* @returns a promise of a string that serves as the Merkle path that can be passed on to the Sapling forger or the transaction builder
|
|
25
|
+
*/
|
|
26
|
+
getWitness(stateTree: SaplingStateTree, position: BigNumber): Promise<string>;
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @param leaves array of leaves or nodes that we want to construct the Merkle tree from
|
|
30
|
+
* @param height height of the desired Merkle tree
|
|
31
|
+
* @returns a promise of MerkleTree type object
|
|
32
|
+
*/
|
|
33
|
+
private constructMerkleTree;
|
|
34
|
+
private getMerkleHash;
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @returns hashes of empty or null values to fill in the Merkle tree
|
|
38
|
+
*/
|
|
39
|
+
private createUncommittedMerkleHashes;
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param tree Merkle tree to validate
|
|
43
|
+
* @param expectedRoot the expected merkle root to validate against
|
|
44
|
+
* @throws {@link InvalidMerkleTreeError}
|
|
45
|
+
*/
|
|
46
|
+
private validateMerkleTree;
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @param acc accumulator variable for the recursive function
|
|
50
|
+
* @param height height of the tree
|
|
51
|
+
* @param position position of the hash we would like find the neighbours of
|
|
52
|
+
* @param tree the Merkle tree that we want to traverse
|
|
53
|
+
* @returns the accumulated Buffer array of neighbouring hashes
|
|
54
|
+
*/
|
|
55
|
+
private getNeighbouringHashes;
|
|
56
|
+
}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* @param leaves nodes in the tree that we would like to make pairs from
|
|
4
|
-
* @returns a paired/chunked array: [a, b, c, d] => [[a, b], [c, d]]
|
|
5
|
-
*/
|
|
6
|
-
export declare function pairNodes<T>(leaves: T[]): (T | undefined)[][];
|
|
7
|
-
/**
|
|
8
|
-
* @description helper function to assist in Lazy initializing an object
|
|
9
|
-
*/
|
|
10
|
-
export declare class Lazy<T> {
|
|
11
|
-
private readonly init;
|
|
12
|
-
private isInitialized;
|
|
13
|
-
private value?;
|
|
14
|
-
constructor(init: () => Promise<T>);
|
|
15
|
-
get(): Promise<T>;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
*
|
|
19
|
-
* @param hex hexadecimal string we would like to swap
|
|
20
|
-
* @returns a hexadecimal string with swapped endians
|
|
21
|
-
*/
|
|
22
|
-
export declare const changeEndianness: (hex: string) => string;
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param leaves nodes in the tree that we would like to make pairs from
|
|
4
|
+
* @returns a paired/chunked array: [a, b, c, d] => [[a, b], [c, d]]
|
|
5
|
+
*/
|
|
6
|
+
export declare function pairNodes<T>(leaves: T[]): (T | undefined)[][];
|
|
7
|
+
/**
|
|
8
|
+
* @description helper function to assist in Lazy initializing an object
|
|
9
|
+
*/
|
|
10
|
+
export declare class Lazy<T> {
|
|
11
|
+
private readonly init;
|
|
12
|
+
private isInitialized;
|
|
13
|
+
private value?;
|
|
14
|
+
constructor(init: () => Promise<T>);
|
|
15
|
+
get(): Promise<T>;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param hex hexadecimal string we would like to swap
|
|
20
|
+
* @returns a hexadecimal string with swapped endians
|
|
21
|
+
*/
|
|
22
|
+
export declare const changeEndianness: (hex: string) => string;
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { SaplingForger } from '../sapling-forger/sapling-forger';
|
|
3
|
-
import BigNumber from 'bignumber.js';
|
|
4
|
-
import { Input, SaplingTransactionOutput, SaplingTransactionInput, ParametersBindingSig, ChosenSpendableInputs, ParametersOutputDescription, ParametersCiphertext, Ciphertext, SaplingContractDetails, SaplingTransaction, SaplingTransactionParams } from '../types';
|
|
5
|
-
import { TzReadProvider } from '@taquito/taquito';
|
|
6
|
-
import { SaplingWrapper } from '../sapling-module-wrapper';
|
|
7
|
-
import { InMemorySpendingKey } from '../sapling-keys/in-memory-spending-key';
|
|
8
|
-
import { InMemoryProvingKey } from '../sapling-keys/in-memory-proving-key';
|
|
9
|
-
export declare class SaplingTransactionBuilder {
|
|
10
|
-
#private;
|
|
11
|
-
constructor(keys: {
|
|
12
|
-
saplingSigner: InMemorySpendingKey;
|
|
13
|
-
saplingProver?: InMemoryProvingKey;
|
|
14
|
-
}, saplingForger: SaplingForger, saplingContractDetails: SaplingContractDetails, readProvider: TzReadProvider, saplingWrapper?: SaplingWrapper);
|
|
15
|
-
createShieldedTx(saplingTransactionParams: SaplingTransactionParams[], txTotalAmount: BigNumber, boundData: Buffer): Promise<Pick<SaplingTransaction, 'inputs' | 'outputs' | 'signature' | 'balance'>>;
|
|
16
|
-
createSaplingTx(saplingTransactionParams: SaplingTransactionParams[], txTotalAmount: BigNumber, boundData: Buffer, chosenInputs: ChosenSpendableInputs): Promise<{
|
|
17
|
-
inputs: SaplingTransactionInput[];
|
|
18
|
-
outputs: SaplingTransactionOutput[];
|
|
19
|
-
signature: Buffer;
|
|
20
|
-
balance: BigNumber;
|
|
21
|
-
}>;
|
|
22
|
-
calculateTransactionBalance(inputTotal: string, outputTotal: string): BigNumber;
|
|
23
|
-
prepareSaplingOutputDescription(parametersOutputDescription: ParametersOutputDescription): Promise<SaplingTransactionOutput>;
|
|
24
|
-
prepareSaplingSpendDescription(saplingContext: number, inputsToSpend: Input[]): Promise<SaplingTransactionInput[]>;
|
|
25
|
-
encryptCiphertext(parametersCiphertext: ParametersCiphertext): Promise<Pick<Ciphertext, 'payloadEnc' | 'nonceEnc' | 'payloadOut' | 'nonceOut'>>;
|
|
26
|
-
createPaybackOutput(params: ParametersOutputDescription, sumSelectedInputs: BigNumber): Promise<{
|
|
27
|
-
payBackOutput: SaplingTransactionOutput;
|
|
28
|
-
payBackAmount: string;
|
|
29
|
-
}>;
|
|
30
|
-
createBindingSignature(parametersBindingSig: ParametersBindingSig): Promise<Buffer>;
|
|
31
|
-
getAntiReplay(): Promise<Buffer>;
|
|
32
|
-
}
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { SaplingForger } from '../sapling-forger/sapling-forger';
|
|
3
|
+
import BigNumber from 'bignumber.js';
|
|
4
|
+
import { Input, SaplingTransactionOutput, SaplingTransactionInput, ParametersBindingSig, ChosenSpendableInputs, ParametersOutputDescription, ParametersCiphertext, Ciphertext, SaplingContractDetails, SaplingTransaction, SaplingTransactionParams } from '../types';
|
|
5
|
+
import { TzReadProvider } from '@taquito/taquito';
|
|
6
|
+
import { SaplingWrapper } from '../sapling-module-wrapper';
|
|
7
|
+
import { InMemorySpendingKey } from '../sapling-keys/in-memory-spending-key';
|
|
8
|
+
import { InMemoryProvingKey } from '../sapling-keys/in-memory-proving-key';
|
|
9
|
+
export declare class SaplingTransactionBuilder {
|
|
10
|
+
#private;
|
|
11
|
+
constructor(keys: {
|
|
12
|
+
saplingSigner: InMemorySpendingKey;
|
|
13
|
+
saplingProver?: InMemoryProvingKey;
|
|
14
|
+
}, saplingForger: SaplingForger, saplingContractDetails: SaplingContractDetails, readProvider: TzReadProvider, saplingWrapper?: SaplingWrapper);
|
|
15
|
+
createShieldedTx(saplingTransactionParams: SaplingTransactionParams[], txTotalAmount: BigNumber, boundData: Buffer): Promise<Pick<SaplingTransaction, 'inputs' | 'outputs' | 'signature' | 'balance'>>;
|
|
16
|
+
createSaplingTx(saplingTransactionParams: SaplingTransactionParams[], txTotalAmount: BigNumber, boundData: Buffer, chosenInputs: ChosenSpendableInputs): Promise<{
|
|
17
|
+
inputs: SaplingTransactionInput[];
|
|
18
|
+
outputs: SaplingTransactionOutput[];
|
|
19
|
+
signature: Buffer;
|
|
20
|
+
balance: BigNumber;
|
|
21
|
+
}>;
|
|
22
|
+
calculateTransactionBalance(inputTotal: string, outputTotal: string): BigNumber;
|
|
23
|
+
prepareSaplingOutputDescription(parametersOutputDescription: ParametersOutputDescription): Promise<SaplingTransactionOutput>;
|
|
24
|
+
prepareSaplingSpendDescription(saplingContext: number, inputsToSpend: Input[]): Promise<SaplingTransactionInput[]>;
|
|
25
|
+
encryptCiphertext(parametersCiphertext: ParametersCiphertext): Promise<Pick<Ciphertext, 'payloadEnc' | 'nonceEnc' | 'payloadOut' | 'nonceOut'>>;
|
|
26
|
+
createPaybackOutput(params: ParametersOutputDescription, sumSelectedInputs: BigNumber): Promise<{
|
|
27
|
+
payBackOutput: SaplingTransactionOutput;
|
|
28
|
+
payBackAmount: string;
|
|
29
|
+
}>;
|
|
30
|
+
createBindingSignature(parametersBindingSig: ParametersBindingSig): Promise<Buffer>;
|
|
31
|
+
getAntiReplay(): Promise<Buffer>;
|
|
32
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import BigNumber from 'bignumber.js';
|
|
3
|
-
import { Input } from '../types';
|
|
4
|
-
export declare function memoHexToUtf8(memo: string): string;
|
|
5
|
-
export declare function readableFormat(saplingTransactionProperties: Omit<Input, 'position'>): {
|
|
6
|
-
value: BigNumber;
|
|
7
|
-
memo: string;
|
|
8
|
-
paymentAddress: string;
|
|
9
|
-
};
|
|
10
|
-
export declare function convertValueToBigNumber(value: Uint8Array): BigNumber;
|
|
11
|
-
export declare function bufToUint8Array(buffer: Buffer): Uint8Array;
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import BigNumber from 'bignumber.js';
|
|
3
|
+
import { Input } from '../types';
|
|
4
|
+
export declare function memoHexToUtf8(memo: string): string;
|
|
5
|
+
export declare function readableFormat(saplingTransactionProperties: Omit<Input, 'position'>): {
|
|
6
|
+
value: BigNumber;
|
|
7
|
+
memo: string;
|
|
8
|
+
paymentAddress: string;
|
|
9
|
+
};
|
|
10
|
+
export declare function convertValueToBigNumber(value: Uint8Array): BigNumber;
|
|
11
|
+
export declare function bufToUint8Array(buffer: Buffer): Uint8Array;
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import BigNumber from 'bignumber.js';
|
|
2
|
-
import { InMemoryViewingKey } from '../sapling-keys/in-memory-viewing-key';
|
|
3
|
-
import { Input, SaplingContractId, SaplingIncomingAndOutgoingTransaction } from '../types';
|
|
4
|
-
import { TzReadProvider } from '@taquito/taquito';
|
|
5
|
-
/**
|
|
6
|
-
* @description Allows to retrieve and decrypt sapling transactions using on a viewing key
|
|
7
|
-
*
|
|
8
|
-
* @param inMemoryViewingKey Holds the sapling viewing key
|
|
9
|
-
* @param saplingContractId Address of the sapling contract or sapling id if the smart contract contains multiple sapling states
|
|
10
|
-
* @param readProvider Allows to read data from the blockchain
|
|
11
|
-
*/
|
|
12
|
-
export declare class SaplingTransactionViewer {
|
|
13
|
-
#private;
|
|
14
|
-
constructor(inMemoryViewingKey: InMemoryViewingKey, saplingContractId: SaplingContractId, readProvider: TzReadProvider);
|
|
15
|
-
/**
|
|
16
|
-
* @description Retrieve the unspent balance associated with the configured viewing key and sapling state
|
|
17
|
-
*
|
|
18
|
-
* @returns the balance in mutez represented as a BigNumber
|
|
19
|
-
*
|
|
20
|
-
*/
|
|
21
|
-
getBalance(): Promise<BigNumber>;
|
|
22
|
-
/**
|
|
23
|
-
* @description Retrieve all the incoming and outgoing transactions associated with the configured viewing key.
|
|
24
|
-
* The response properties are in Uint8Array format; use the getIncomingAndOutgoingTransactions method for readable properties
|
|
25
|
-
*
|
|
26
|
-
*/
|
|
27
|
-
getIncomingAndOutgoingTransactionsRaw(): Promise<{
|
|
28
|
-
incoming: {
|
|
29
|
-
isSpent: boolean;
|
|
30
|
-
position: number;
|
|
31
|
-
value: Uint8Array;
|
|
32
|
-
memo: Uint8Array;
|
|
33
|
-
paymentAddress: Uint8Array;
|
|
34
|
-
randomCommitmentTrapdoor: Uint8Array;
|
|
35
|
-
}[];
|
|
36
|
-
outgoing: Omit<Input, "position">[];
|
|
37
|
-
}>;
|
|
38
|
-
/**
|
|
39
|
-
* @description Retrieve all the incoming and outgoing decoded transactions associated with the configured viewing key
|
|
40
|
-
*
|
|
41
|
-
*/
|
|
42
|
-
getIncomingAndOutgoingTransactions(): Promise<SaplingIncomingAndOutgoingTransaction>;
|
|
43
|
-
private getSaplingDiff;
|
|
44
|
-
private decryptCiphertextAsReceiver;
|
|
45
|
-
private decryptCiphertextAsSender;
|
|
46
|
-
private decryptCiphertext;
|
|
47
|
-
private extractTransactionProperties;
|
|
48
|
-
private extractPkdAndEsk;
|
|
49
|
-
private isSpent;
|
|
50
|
-
}
|
|
1
|
+
import BigNumber from 'bignumber.js';
|
|
2
|
+
import { InMemoryViewingKey } from '../sapling-keys/in-memory-viewing-key';
|
|
3
|
+
import { Input, SaplingContractId, SaplingIncomingAndOutgoingTransaction } from '../types';
|
|
4
|
+
import { TzReadProvider } from '@taquito/taquito';
|
|
5
|
+
/**
|
|
6
|
+
* @description Allows to retrieve and decrypt sapling transactions using on a viewing key
|
|
7
|
+
*
|
|
8
|
+
* @param inMemoryViewingKey Holds the sapling viewing key
|
|
9
|
+
* @param saplingContractId Address of the sapling contract or sapling id if the smart contract contains multiple sapling states
|
|
10
|
+
* @param readProvider Allows to read data from the blockchain
|
|
11
|
+
*/
|
|
12
|
+
export declare class SaplingTransactionViewer {
|
|
13
|
+
#private;
|
|
14
|
+
constructor(inMemoryViewingKey: InMemoryViewingKey, saplingContractId: SaplingContractId, readProvider: TzReadProvider);
|
|
15
|
+
/**
|
|
16
|
+
* @description Retrieve the unspent balance associated with the configured viewing key and sapling state
|
|
17
|
+
*
|
|
18
|
+
* @returns the balance in mutez represented as a BigNumber
|
|
19
|
+
*
|
|
20
|
+
*/
|
|
21
|
+
getBalance(): Promise<BigNumber>;
|
|
22
|
+
/**
|
|
23
|
+
* @description Retrieve all the incoming and outgoing transactions associated with the configured viewing key.
|
|
24
|
+
* The response properties are in Uint8Array format; use the getIncomingAndOutgoingTransactions method for readable properties
|
|
25
|
+
*
|
|
26
|
+
*/
|
|
27
|
+
getIncomingAndOutgoingTransactionsRaw(): Promise<{
|
|
28
|
+
incoming: {
|
|
29
|
+
isSpent: boolean;
|
|
30
|
+
position: number;
|
|
31
|
+
value: Uint8Array;
|
|
32
|
+
memo: Uint8Array;
|
|
33
|
+
paymentAddress: Uint8Array;
|
|
34
|
+
randomCommitmentTrapdoor: Uint8Array;
|
|
35
|
+
}[];
|
|
36
|
+
outgoing: Omit<Input, "position">[];
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* @description Retrieve all the incoming and outgoing decoded transactions associated with the configured viewing key
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
getIncomingAndOutgoingTransactions(): Promise<SaplingIncomingAndOutgoingTransaction>;
|
|
43
|
+
private getSaplingDiff;
|
|
44
|
+
private decryptCiphertextAsReceiver;
|
|
45
|
+
private decryptCiphertextAsSender;
|
|
46
|
+
private decryptCiphertext;
|
|
47
|
+
private extractTransactionProperties;
|
|
48
|
+
private extractPkdAndEsk;
|
|
49
|
+
private isSpent;
|
|
50
|
+
}
|