@thesingularitynetwork/darkswap-sdk 0.1.2 → 0.1.3
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/index.esm.js +16 -10
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +16 -10
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +18 -11
- package/dist/index.umd.js.map +1 -1
- package/dist/types/src/services/noteService.d.ts +1 -0
- package/package.json +2 -2
- package/src/services/noteService.ts +12 -0
package/dist/index.esm.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ethers, AbiCoder, ripemd160, hexlify } from 'ethers';
|
|
2
|
-
import { UltraHonkBackend } from '@aztec/bb.js';
|
|
3
2
|
import { Schnorr } from '@aztec/foundation/crypto';
|
|
3
|
+
import { Fr, Fq } from '@aztec/foundation/fields';
|
|
4
|
+
import { UltraHonkBackend } from '@aztec/bb.js';
|
|
4
5
|
import { Noir } from '@noir-lang/noir_js';
|
|
5
|
-
import { Fq, Fr } from '@aztec/foundation/fields';
|
|
6
6
|
|
|
7
7
|
const NATIVE_ASSETS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
8
8
|
function isNativeAsset(asset) {
|
|
@@ -804,6 +804,13 @@ function createOrderNoteExt(address, asset, amount, feeRatio, fuzkPubKey) {
|
|
|
804
804
|
};
|
|
805
805
|
}
|
|
806
806
|
|
|
807
|
+
async function generateKeyPair(signature) {
|
|
808
|
+
const privateKey = Fr.fromBufferReduce(Buffer.from(signature.replace("0x", ""), "hex"));
|
|
809
|
+
const schnorr = new Schnorr();
|
|
810
|
+
const publicKey = await schnorr.computePublicKey(Fq.fromBufferReduce(privateKey.toBuffer()));
|
|
811
|
+
return [[publicKey.x, publicKey.y], privateKey];
|
|
812
|
+
}
|
|
813
|
+
|
|
807
814
|
function getContract$1(address, darkSwap) {
|
|
808
815
|
const provider = darkSwap.provider;
|
|
809
816
|
return new ethers.Contract(address, MerkleAbi.abi, provider);
|
|
@@ -829,6 +836,12 @@ async function getNoteOnChainStatusByPublicKey(darkSwap, note, publicKey) {
|
|
|
829
836
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
830
837
|
return onChainStatus;
|
|
831
838
|
}
|
|
839
|
+
async function getNoteOnChainStatusBySignature(darkSwap, note, signature) {
|
|
840
|
+
const [publicKey] = await generateKeyPair(signature);
|
|
841
|
+
const nullifier = calcNullifier(note.rho, publicKey);
|
|
842
|
+
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
843
|
+
return onChainStatus;
|
|
844
|
+
}
|
|
832
845
|
async function isNoteActive(darkSwap, note, publicKey) {
|
|
833
846
|
const nullifier = calcNullifier(note.rho, publicKey);
|
|
834
847
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
@@ -2690,13 +2703,6 @@ async function signMessage(message, fuzkPriKey) {
|
|
|
2690
2703
|
return signature.toBuffer();
|
|
2691
2704
|
}
|
|
2692
2705
|
|
|
2693
|
-
async function generateKeyPair(signature) {
|
|
2694
|
-
const privateKey = Fr.fromBufferReduce(Buffer.from(signature.replace("0x", ""), "hex"));
|
|
2695
|
-
const schnorr = new Schnorr();
|
|
2696
|
-
const publicKey = await schnorr.computePublicKey(Fq.fromBufferReduce(privateKey.toBuffer()));
|
|
2697
|
-
return [[publicKey.x, publicKey.y], privateKey];
|
|
2698
|
-
}
|
|
2699
|
-
|
|
2700
2706
|
async function generateDepositProof(param) {
|
|
2701
2707
|
const depositAmount = param.newBalanceNote.amount - param.oldBalanceNote.amount;
|
|
2702
2708
|
if (depositAmount <= 0) {
|
|
@@ -5183,5 +5189,5 @@ class DarkSwap {
|
|
|
5183
5189
|
}
|
|
5184
5190
|
}
|
|
5185
5191
|
|
|
5186
|
-
export { ChainId, DarkSwap, DarkSwapError, DarkSwapProofError, DepositContext, DepositService, EMPTY_FOOTER, EMPTY_NULLIFIER, EMPTY_PATH, FEE_RATIO, FEE_RATIO_PRECISION, JoinService, NoteOnChainStatus, PROOF_DOMAIN, ProCreateOrderService, RetailCancelOrderService, RetailCreateOrderService, TripleJoinService, WithdrawService, contractConfig, generateKeyPair, getMerklePathAndRoot, getNoteOnChainStatusByPublicKey, hexlify32, isAddressEquals, isHexEquals, isNativeAsset, isNoteActive, isNoteSpent, isNoteValid, legacyTokenConfig, multiGetMerklePathAndRoot };
|
|
5192
|
+
export { ChainId, DarkSwap, DarkSwapError, DarkSwapProofError, DepositContext, DepositService, EMPTY_FOOTER, EMPTY_NULLIFIER, EMPTY_PATH, FEE_RATIO, FEE_RATIO_PRECISION, JoinService, NoteOnChainStatus, PROOF_DOMAIN, ProCreateOrderService, RetailCancelOrderService, RetailCreateOrderService, TripleJoinService, WithdrawService, contractConfig, generateKeyPair, getMerklePathAndRoot, getNoteOnChainStatusByPublicKey, getNoteOnChainStatusBySignature, hexlify32, isAddressEquals, isHexEquals, isNativeAsset, isNoteActive, isNoteSpent, isNoteValid, legacyTokenConfig, multiGetMerklePathAndRoot };
|
|
5187
5193
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { ethers, AbiCoder, ripemd160, hexlify } from 'ethers';
|
|
2
|
-
import { UltraHonkBackend } from '@aztec/bb.js';
|
|
3
2
|
import { Schnorr } from '@aztec/foundation/crypto';
|
|
3
|
+
import { Fr, Fq } from '@aztec/foundation/fields';
|
|
4
|
+
import { UltraHonkBackend } from '@aztec/bb.js';
|
|
4
5
|
import { Noir } from '@noir-lang/noir_js';
|
|
5
|
-
import { Fq, Fr } from '@aztec/foundation/fields';
|
|
6
6
|
|
|
7
7
|
const NATIVE_ASSETS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
8
8
|
function isNativeAsset(asset) {
|
|
@@ -804,6 +804,13 @@ function createOrderNoteExt(address, asset, amount, feeRatio, fuzkPubKey) {
|
|
|
804
804
|
};
|
|
805
805
|
}
|
|
806
806
|
|
|
807
|
+
async function generateKeyPair(signature) {
|
|
808
|
+
const privateKey = Fr.fromBufferReduce(Buffer.from(signature.replace("0x", ""), "hex"));
|
|
809
|
+
const schnorr = new Schnorr();
|
|
810
|
+
const publicKey = await schnorr.computePublicKey(Fq.fromBufferReduce(privateKey.toBuffer()));
|
|
811
|
+
return [[publicKey.x, publicKey.y], privateKey];
|
|
812
|
+
}
|
|
813
|
+
|
|
807
814
|
function getContract$1(address, darkSwap) {
|
|
808
815
|
const provider = darkSwap.provider;
|
|
809
816
|
return new ethers.Contract(address, MerkleAbi.abi, provider);
|
|
@@ -829,6 +836,12 @@ async function getNoteOnChainStatusByPublicKey(darkSwap, note, publicKey) {
|
|
|
829
836
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
830
837
|
return onChainStatus;
|
|
831
838
|
}
|
|
839
|
+
async function getNoteOnChainStatusBySignature(darkSwap, note, signature) {
|
|
840
|
+
const [publicKey] = await generateKeyPair(signature);
|
|
841
|
+
const nullifier = calcNullifier(note.rho, publicKey);
|
|
842
|
+
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
843
|
+
return onChainStatus;
|
|
844
|
+
}
|
|
832
845
|
async function isNoteActive(darkSwap, note, publicKey) {
|
|
833
846
|
const nullifier = calcNullifier(note.rho, publicKey);
|
|
834
847
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
@@ -2690,13 +2703,6 @@ async function signMessage(message, fuzkPriKey) {
|
|
|
2690
2703
|
return signature.toBuffer();
|
|
2691
2704
|
}
|
|
2692
2705
|
|
|
2693
|
-
async function generateKeyPair(signature) {
|
|
2694
|
-
const privateKey = Fr.fromBufferReduce(Buffer.from(signature.replace("0x", ""), "hex"));
|
|
2695
|
-
const schnorr = new Schnorr();
|
|
2696
|
-
const publicKey = await schnorr.computePublicKey(Fq.fromBufferReduce(privateKey.toBuffer()));
|
|
2697
|
-
return [[publicKey.x, publicKey.y], privateKey];
|
|
2698
|
-
}
|
|
2699
|
-
|
|
2700
2706
|
async function generateDepositProof(param) {
|
|
2701
2707
|
const depositAmount = param.newBalanceNote.amount - param.oldBalanceNote.amount;
|
|
2702
2708
|
if (depositAmount <= 0) {
|
|
@@ -5183,5 +5189,5 @@ class DarkSwap {
|
|
|
5183
5189
|
}
|
|
5184
5190
|
}
|
|
5185
5191
|
|
|
5186
|
-
export { ChainId, DarkSwap, DarkSwapError, DarkSwapProofError, DepositContext, DepositService, EMPTY_FOOTER, EMPTY_NULLIFIER, EMPTY_PATH, FEE_RATIO, FEE_RATIO_PRECISION, JoinService, NoteOnChainStatus, PROOF_DOMAIN, ProCreateOrderService, RetailCancelOrderService, RetailCreateOrderService, TripleJoinService, WithdrawService, contractConfig, generateKeyPair, getMerklePathAndRoot, getNoteOnChainStatusByPublicKey, hexlify32, isAddressEquals, isHexEquals, isNativeAsset, isNoteActive, isNoteSpent, isNoteValid, legacyTokenConfig, multiGetMerklePathAndRoot };
|
|
5192
|
+
export { ChainId, DarkSwap, DarkSwapError, DarkSwapProofError, DepositContext, DepositService, EMPTY_FOOTER, EMPTY_NULLIFIER, EMPTY_PATH, FEE_RATIO, FEE_RATIO_PRECISION, JoinService, NoteOnChainStatus, PROOF_DOMAIN, ProCreateOrderService, RetailCancelOrderService, RetailCreateOrderService, TripleJoinService, WithdrawService, contractConfig, generateKeyPair, getMerklePathAndRoot, getNoteOnChainStatusByPublicKey, getNoteOnChainStatusBySignature, hexlify32, isAddressEquals, isHexEquals, isNativeAsset, isNoteActive, isNoteSpent, isNoteValid, legacyTokenConfig, multiGetMerklePathAndRoot };
|
|
5187
5193
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/dist/index.umd.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
(function (global, factory) {
|
|
2
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('ethers'), require('@aztec/
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'ethers', '@aztec/
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.DarkSwapSDK = {}, global.ethers, global.
|
|
5
|
-
})(this, (function (exports, ethers,
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('ethers'), require('@aztec/foundation/crypto'), require('@aztec/foundation/fields'), require('@aztec/bb.js'), require('@noir-lang/noir_js')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', 'ethers', '@aztec/foundation/crypto', '@aztec/foundation/fields', '@aztec/bb.js', '@noir-lang/noir_js'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.DarkSwapSDK = {}, global.ethers, global.crypto, global.fields, global.AztecBB, global.NoirJS));
|
|
5
|
+
})(this, (function (exports, ethers, crypto, fields, bb_js, noir_js) { 'use strict';
|
|
6
6
|
|
|
7
7
|
const NATIVE_ASSETS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE';
|
|
8
8
|
function isNativeAsset(asset) {
|
|
@@ -804,6 +804,13 @@
|
|
|
804
804
|
};
|
|
805
805
|
}
|
|
806
806
|
|
|
807
|
+
async function generateKeyPair(signature) {
|
|
808
|
+
const privateKey = fields.Fr.fromBufferReduce(Buffer.from(signature.replace("0x", ""), "hex"));
|
|
809
|
+
const schnorr = new crypto.Schnorr();
|
|
810
|
+
const publicKey = await schnorr.computePublicKey(fields.Fq.fromBufferReduce(privateKey.toBuffer()));
|
|
811
|
+
return [[publicKey.x, publicKey.y], privateKey];
|
|
812
|
+
}
|
|
813
|
+
|
|
807
814
|
function getContract$1(address, darkSwap) {
|
|
808
815
|
const provider = darkSwap.provider;
|
|
809
816
|
return new ethers.ethers.Contract(address, MerkleAbi.abi, provider);
|
|
@@ -829,6 +836,12 @@
|
|
|
829
836
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
830
837
|
return onChainStatus;
|
|
831
838
|
}
|
|
839
|
+
async function getNoteOnChainStatusBySignature(darkSwap, note, signature) {
|
|
840
|
+
const [publicKey] = await generateKeyPair(signature);
|
|
841
|
+
const nullifier = calcNullifier(note.rho, publicKey);
|
|
842
|
+
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
843
|
+
return onChainStatus;
|
|
844
|
+
}
|
|
832
845
|
async function isNoteActive(darkSwap, note, publicKey) {
|
|
833
846
|
const nullifier = calcNullifier(note.rho, publicKey);
|
|
834
847
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
@@ -2690,13 +2703,6 @@
|
|
|
2690
2703
|
return signature.toBuffer();
|
|
2691
2704
|
}
|
|
2692
2705
|
|
|
2693
|
-
async function generateKeyPair(signature) {
|
|
2694
|
-
const privateKey = fields.Fr.fromBufferReduce(Buffer.from(signature.replace("0x", ""), "hex"));
|
|
2695
|
-
const schnorr = new crypto.Schnorr();
|
|
2696
|
-
const publicKey = await schnorr.computePublicKey(fields.Fq.fromBufferReduce(privateKey.toBuffer()));
|
|
2697
|
-
return [[publicKey.x, publicKey.y], privateKey];
|
|
2698
|
-
}
|
|
2699
|
-
|
|
2700
2706
|
async function generateDepositProof(param) {
|
|
2701
2707
|
const depositAmount = param.newBalanceNote.amount - param.oldBalanceNote.amount;
|
|
2702
2708
|
if (depositAmount <= 0) {
|
|
@@ -5203,6 +5209,7 @@
|
|
|
5203
5209
|
exports.generateKeyPair = generateKeyPair;
|
|
5204
5210
|
exports.getMerklePathAndRoot = getMerklePathAndRoot;
|
|
5205
5211
|
exports.getNoteOnChainStatusByPublicKey = getNoteOnChainStatusByPublicKey;
|
|
5212
|
+
exports.getNoteOnChainStatusBySignature = getNoteOnChainStatusBySignature;
|
|
5206
5213
|
exports.hexlify32 = hexlify32;
|
|
5207
5214
|
exports.isAddressEquals = isAddressEquals;
|
|
5208
5215
|
exports.isHexEquals = isHexEquals;
|
package/dist/index.umd.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -3,6 +3,7 @@ import { DarkSwap } from '../darkSwap';
|
|
|
3
3
|
import { DarkSwapNote } from '../types';
|
|
4
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
5
|
export declare function getNoteOnChainStatusByPublicKey(darkSwap: DarkSwap, note: DarkSwapNote, publicKey: [Fr, Fr]): Promise<NoteOnChainStatus>;
|
|
6
|
+
export declare function getNoteOnChainStatusBySignature(darkSwap: DarkSwap, note: DarkSwapNote, signature: string): Promise<NoteOnChainStatus>;
|
|
6
7
|
export declare function isNoteActive(darkSwap: DarkSwap, note: DarkSwapNote, publicKey: [Fr, Fr]): Promise<boolean>;
|
|
7
8
|
export declare function isNoteSpent(darkSwap: DarkSwap, note: DarkSwapNote, publicKey: [Fr, Fr]): Promise<boolean>;
|
|
8
9
|
export declare function isNoteValid(darkSwap: DarkSwap, note: DarkSwapNote, publicKey: [Fr, Fr]): Promise<boolean>;
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thesingularitynetwork/darkswap-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "DarkSwap SDK for browser and Node.js",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"types": "dist/types/index.d.ts",
|
|
6
|
+
"types": "dist/types/src/index.d.ts",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
@@ -6,6 +6,7 @@ import { DarkSwap } from '../darkSwap';
|
|
|
6
6
|
import { DarkSwapNote } from '../types';
|
|
7
7
|
import { Fr } from '@aztec/foundation/fields';
|
|
8
8
|
import { calcNullifier } from '../proof/noteService';
|
|
9
|
+
import { generateKeyPair } from '../proof/keyService';
|
|
9
10
|
|
|
10
11
|
function getContract(address: string, darkSwap: DarkSwap) {
|
|
11
12
|
const provider = darkSwap.provider;
|
|
@@ -39,6 +40,17 @@ export async function getNoteOnChainStatusByPublicKey(
|
|
|
39
40
|
return onChainStatus;
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
export async function getNoteOnChainStatusBySignature(
|
|
44
|
+
darkSwap: DarkSwap,
|
|
45
|
+
note: DarkSwapNote,
|
|
46
|
+
signature: string
|
|
47
|
+
): Promise<NoteOnChainStatus> {
|
|
48
|
+
const [publicKey] = await generateKeyPair(signature);
|
|
49
|
+
const nullifier = calcNullifier(note.rho, publicKey);
|
|
50
|
+
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|
|
51
|
+
return onChainStatus;
|
|
52
|
+
}
|
|
53
|
+
|
|
42
54
|
export async function isNoteActive(darkSwap: DarkSwap, note: DarkSwapNote, publicKey: [Fr, Fr]): Promise<boolean> {
|
|
43
55
|
const nullifier = calcNullifier(note.rho, publicKey);
|
|
44
56
|
const onChainStatus = await getNoteOnChainStatus(darkSwap, hexlify32(note.note), hexlify32(nullifier));
|