@thesingularitynetwork/darkswap-sdk 0.1.14 → 0.1.16
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 +20 -16
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +129 -80
- package/dist/index.js.map +1 -1
- package/dist/types/src/proof/noteService.d.ts +2 -2
- package/package.json +2 -1
- package/src/proof/noteService.ts +86 -80
- package/dist/index.umd.js +0 -7487
- package/dist/index.umd.js.map +0 -1
- package/dist/types/src/services/pro/swapMessage.d.ts +0 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ethers, AbiCoder, ripemd160, hexlify } from 'ethers';
|
|
2
|
+
import cryptoJs from 'crypto-js';
|
|
2
3
|
import { Schnorr } from '@aztec/foundation/crypto';
|
|
3
4
|
import { Fr, Fq } from '@aztec/foundation/fields';
|
|
4
5
|
import { UltraHonkBackend } from '@aztec/bb.js';
|
|
@@ -731,13 +732,14 @@ function mimc_bn254(array) {
|
|
|
731
732
|
}
|
|
732
733
|
|
|
733
734
|
let getRandomValues;
|
|
734
|
-
if (typeof window !== 'undefined' &&
|
|
735
|
+
if (typeof window !== 'undefined' &&
|
|
736
|
+
window.crypto &&
|
|
737
|
+
window.crypto.getRandomValues) {
|
|
735
738
|
getRandomValues = (buf) => window.crypto.getRandomValues(buf);
|
|
736
739
|
}
|
|
737
740
|
else {
|
|
738
|
-
const nodeCrypto = require('crypto');
|
|
739
741
|
getRandomValues = (buf) => {
|
|
740
|
-
const randomBytes =
|
|
742
|
+
const randomBytes = cryptoJs.randomBytes(buf.length);
|
|
741
743
|
buf.set(randomBytes);
|
|
742
744
|
return buf;
|
|
743
745
|
};
|
|
@@ -748,30 +750,28 @@ const EMPTY_NOTE = {
|
|
|
748
750
|
rho: 0n,
|
|
749
751
|
note: 0n,
|
|
750
752
|
amount: 0n,
|
|
751
|
-
asset: '0x0000000000000000000000000000000000000000'
|
|
753
|
+
asset: '0x0000000000000000000000000000000000000000',
|
|
752
754
|
};
|
|
753
755
|
function createNote(address, asset, amount, fuzkPubKey) {
|
|
754
756
|
const rho = generateRho();
|
|
755
757
|
const footer = getNoteFooter(rho, fuzkPubKey);
|
|
756
758
|
const addressMod = encodeAddress(address);
|
|
757
759
|
const assetMod = encodeAddress(asset);
|
|
758
|
-
const note = mimc_bn254([
|
|
759
|
-
DOMAIN_NOTE,
|
|
760
|
-
addressMod,
|
|
761
|
-
assetMod,
|
|
762
|
-
amount,
|
|
763
|
-
footer
|
|
764
|
-
]);
|
|
760
|
+
const note = mimc_bn254([DOMAIN_NOTE, addressMod, assetMod, amount, footer]);
|
|
765
761
|
return {
|
|
766
762
|
rho,
|
|
767
763
|
note,
|
|
768
764
|
asset,
|
|
769
765
|
amount,
|
|
770
|
-
footer
|
|
766
|
+
footer,
|
|
771
767
|
};
|
|
772
768
|
}
|
|
773
769
|
function getNoteFooter(rho, publicKey) {
|
|
774
|
-
return mimc_bn254([
|
|
770
|
+
return mimc_bn254([
|
|
771
|
+
mimc_bn254([BigInt(rho)]),
|
|
772
|
+
BigInt(publicKey[0].toString()),
|
|
773
|
+
BigInt(publicKey[1].toString()),
|
|
774
|
+
]);
|
|
775
775
|
}
|
|
776
776
|
function generateRho() {
|
|
777
777
|
const securityLevel = 128;
|
|
@@ -786,7 +786,11 @@ function generateRho() {
|
|
|
786
786
|
return rho;
|
|
787
787
|
}
|
|
788
788
|
function calcNullifier(rho, fuzkPubKey) {
|
|
789
|
-
return mimc_bn254([
|
|
789
|
+
return mimc_bn254([
|
|
790
|
+
rho,
|
|
791
|
+
BigInt(fuzkPubKey[0].toString()),
|
|
792
|
+
BigInt(fuzkPubKey[1].toString()),
|
|
793
|
+
]);
|
|
790
794
|
}
|
|
791
795
|
function createOrderNoteExt(address, asset, amount, feeRatio, fuzkPubKey) {
|
|
792
796
|
const rho = generateRho();
|
|
@@ -799,14 +803,14 @@ function createOrderNoteExt(address, asset, amount, feeRatio, fuzkPubKey) {
|
|
|
799
803
|
assetMod,
|
|
800
804
|
amount,
|
|
801
805
|
feeRatio,
|
|
802
|
-
footer
|
|
806
|
+
footer,
|
|
803
807
|
]);
|
|
804
808
|
return {
|
|
805
809
|
rho,
|
|
806
810
|
note: noteCommitment,
|
|
807
811
|
asset,
|
|
808
812
|
amount,
|
|
809
|
-
feeRatio
|
|
813
|
+
feeRatio,
|
|
810
814
|
};
|
|
811
815
|
}
|
|
812
816
|
|
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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