@thesingularitynetwork/darkswap-sdk 0.1.15 → 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 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' && window.crypto && window.crypto.getRandomValues) {
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 = nodeCrypto.randomBytes(buf.length);
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([mimc_bn254([BigInt(rho)]), BigInt(publicKey[0].toString()), BigInt(publicKey[1].toString())]);
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([rho, BigInt(fuzkPubKey[0].toString()), BigInt(fuzkPubKey[1].toString())]);
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
 
@@ -1 +1 @@
1
- {"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var ethers = require('ethers');
4
+ var cryptoJs = require('crypto-js');
4
5
  var crypto = require('@aztec/foundation/crypto');
5
6
  var fields = require('@aztec/foundation/fields');
6
7
  var bb_js = require('@aztec/bb.js');
@@ -733,13 +734,14 @@ function mimc_bn254(array) {
733
734
  }
734
735
 
735
736
  let getRandomValues;
736
- if (typeof window !== 'undefined' && window.crypto && window.crypto.getRandomValues) {
737
+ if (typeof window !== 'undefined' &&
738
+ window.crypto &&
739
+ window.crypto.getRandomValues) {
737
740
  getRandomValues = (buf) => window.crypto.getRandomValues(buf);
738
741
  }
739
742
  else {
740
- const nodeCrypto = require('crypto');
741
743
  getRandomValues = (buf) => {
742
- const randomBytes = nodeCrypto.randomBytes(buf.length);
744
+ const randomBytes = cryptoJs.randomBytes(buf.length);
743
745
  buf.set(randomBytes);
744
746
  return buf;
745
747
  };
@@ -750,30 +752,28 @@ const EMPTY_NOTE = {
750
752
  rho: 0n,
751
753
  note: 0n,
752
754
  amount: 0n,
753
- asset: '0x0000000000000000000000000000000000000000'
755
+ asset: '0x0000000000000000000000000000000000000000',
754
756
  };
755
757
  function createNote(address, asset, amount, fuzkPubKey) {
756
758
  const rho = generateRho();
757
759
  const footer = getNoteFooter(rho, fuzkPubKey);
758
760
  const addressMod = encodeAddress(address);
759
761
  const assetMod = encodeAddress(asset);
760
- const note = mimc_bn254([
761
- DOMAIN_NOTE,
762
- addressMod,
763
- assetMod,
764
- amount,
765
- footer
766
- ]);
762
+ const note = mimc_bn254([DOMAIN_NOTE, addressMod, assetMod, amount, footer]);
767
763
  return {
768
764
  rho,
769
765
  note,
770
766
  asset,
771
767
  amount,
772
- footer
768
+ footer,
773
769
  };
774
770
  }
775
771
  function getNoteFooter(rho, publicKey) {
776
- return mimc_bn254([mimc_bn254([BigInt(rho)]), BigInt(publicKey[0].toString()), BigInt(publicKey[1].toString())]);
772
+ return mimc_bn254([
773
+ mimc_bn254([BigInt(rho)]),
774
+ BigInt(publicKey[0].toString()),
775
+ BigInt(publicKey[1].toString()),
776
+ ]);
777
777
  }
778
778
  function generateRho() {
779
779
  const securityLevel = 128;
@@ -788,7 +788,11 @@ function generateRho() {
788
788
  return rho;
789
789
  }
790
790
  function calcNullifier(rho, fuzkPubKey) {
791
- return mimc_bn254([rho, BigInt(fuzkPubKey[0].toString()), BigInt(fuzkPubKey[1].toString())]);
791
+ return mimc_bn254([
792
+ rho,
793
+ BigInt(fuzkPubKey[0].toString()),
794
+ BigInt(fuzkPubKey[1].toString()),
795
+ ]);
792
796
  }
793
797
  function createOrderNoteExt(address, asset, amount, feeRatio, fuzkPubKey) {
794
798
  const rho = generateRho();
@@ -801,14 +805,14 @@ function createOrderNoteExt(address, asset, amount, feeRatio, fuzkPubKey) {
801
805
  assetMod,
802
806
  amount,
803
807
  feeRatio,
804
- footer
808
+ footer,
805
809
  ]);
806
810
  return {
807
811
  rho,
808
812
  note: noteCommitment,
809
813
  asset,
810
814
  amount,
811
- feeRatio
815
+ feeRatio,
812
816
  };
813
817
  }
814
818
 
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,5 +1,5 @@
1
- import { Fr } from "@aztec/foundation/fields";
2
- import { DarkSwapNote, DarkSwapNoteExt, DarkSwapOrderNote } from "../types.js";
1
+ import { Fr } from '@aztec/foundation/fields';
2
+ import { DarkSwapNote, DarkSwapNoteExt, DarkSwapOrderNote } from '../types.js';
3
3
  export declare const DOMAIN_NOTE = 2n;
4
4
  export declare const DOMAIN_ORDER_NOTE = 3n;
5
5
  export declare const EMPTY_NOTE: DarkSwapNote;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thesingularitynetwork/darkswap-sdk",
3
- "version": "0.1.15",
3
+ "version": "0.1.16",
4
4
  "description": "DarkSwap SDK for browser and Node.js",
5
5
  "type": "module",
6
6
  "types": "dist/types/src/index.d.ts",
@@ -49,6 +49,7 @@
49
49
  "@noir-lang/noir_js": "^1.0.0-beta.3",
50
50
  "@noir-lang/noir_wasm": "^1.0.0-beta.3",
51
51
  "@noir-lang/types": "^1.0.0-beta.3",
52
+ "crypto-js": "^4.2.0",
52
53
  "ethers": "^6.14.3"
53
54
  }
54
55
  }
@@ -1,109 +1,115 @@
1
- import { Fr } from "@aztec/foundation/fields";
2
- import { hexlify } from "ethers";
3
- import { DarkSwapNote, DarkSwapNoteExt, DarkSwapOrderNote } from "../types.js";
4
- import { P } from "../utils/constants.js";
5
- import { encodeAddress } from "../utils/encoders.js";
6
- import { mimc_bn254 } from "../utils/mimc.js";
1
+ import { Fr } from '@aztec/foundation/fields'
2
+ import { hexlify } from 'ethers'
3
+ import { DarkSwapNote, DarkSwapNoteExt, DarkSwapOrderNote } from '../types.js'
4
+ import { P } from '../utils/constants.js'
5
+ import { encodeAddress } from '../utils/encoders.js'
6
+ import { mimc_bn254 } from '../utils/mimc.js'
7
+ import cryptoJs from 'crypto-js'
7
8
 
8
- let getRandomValues: (buf: Uint8Array) => Uint8Array;
9
+ let getRandomValues: (buf: Uint8Array) => Uint8Array
9
10
 
10
- if (typeof window !== 'undefined' && window.crypto && window.crypto.getRandomValues) {
11
- getRandomValues = (buf) => window.crypto.getRandomValues(buf);
11
+ if (
12
+ typeof window !== 'undefined' &&
13
+ window.crypto &&
14
+ window.crypto.getRandomValues
15
+ ) {
16
+ getRandomValues = (buf) => window.crypto.getRandomValues(buf)
12
17
  } else {
13
- const nodeCrypto = require('crypto');
14
- getRandomValues = (buf) => {
15
- const randomBytes = nodeCrypto.randomBytes(buf.length);
16
- buf.set(randomBytes);
17
- return buf;
18
- };
18
+ getRandomValues = (buf) => {
19
+ const randomBytes = cryptoJs.randomBytes(buf.length)
20
+ buf.set(randomBytes)
21
+ return buf
22
+ }
19
23
  }
20
24
 
21
- export const DOMAIN_NOTE = 2n;
22
- export const DOMAIN_ORDER_NOTE = 3n;
25
+ export const DOMAIN_NOTE = 2n
26
+ export const DOMAIN_ORDER_NOTE = 3n
23
27
 
24
28
  export const EMPTY_NOTE: DarkSwapNote = {
25
- rho: 0n,
26
- note: 0n,
27
- amount: 0n,
28
- asset: '0x0000000000000000000000000000000000000000'
29
+ rho: 0n,
30
+ note: 0n,
31
+ amount: 0n,
32
+ asset: '0x0000000000000000000000000000000000000000',
29
33
  }
30
34
 
31
35
  export function createNote(
32
- address: string,
33
- asset: string,
34
- amount: bigint,
35
- fuzkPubKey: [Fr, Fr]
36
+ address: string,
37
+ asset: string,
38
+ amount: bigint,
39
+ fuzkPubKey: [Fr, Fr]
36
40
  ): DarkSwapNoteExt {
37
- const rho = generateRho();
38
- const footer = getNoteFooter(rho, fuzkPubKey)
41
+ const rho = generateRho()
42
+ const footer = getNoteFooter(rho, fuzkPubKey)
39
43
 
40
- const addressMod = encodeAddress(address);
41
- const assetMod = encodeAddress(asset);
42
- const note = mimc_bn254([
43
- DOMAIN_NOTE,
44
- addressMod,
45
- assetMod,
46
- amount,
47
- footer
48
- ]);
49
- return {
50
- rho,
51
- note,
52
- asset,
53
- amount,
54
- footer
55
- };
44
+ const addressMod = encodeAddress(address)
45
+ const assetMod = encodeAddress(asset)
46
+ const note = mimc_bn254([DOMAIN_NOTE, addressMod, assetMod, amount, footer])
47
+ return {
48
+ rho,
49
+ note,
50
+ asset,
51
+ amount,
52
+ footer,
53
+ }
56
54
  }
57
55
 
58
56
  export function getNoteFooter(rho: bigint, publicKey: [Fr, Fr]): bigint {
59
- return mimc_bn254([mimc_bn254([BigInt(rho)]), BigInt(publicKey[0].toString()), BigInt(publicKey[1].toString())]);
57
+ return mimc_bn254([
58
+ mimc_bn254([BigInt(rho)]),
59
+ BigInt(publicKey[0].toString()),
60
+ BigInt(publicKey[1].toString()),
61
+ ])
60
62
  }
61
63
 
62
64
  function generateRho(): bigint {
63
- const securityLevel = 128;
64
- const primeByteLength = Math.ceil(P.toString(2).length / 8);
65
- const totalBytes = primeByteLength + Math.ceil(securityLevel / 8);
65
+ const securityLevel = 128
66
+ const primeByteLength = Math.ceil(P.toString(2).length / 8)
67
+ const totalBytes = primeByteLength + Math.ceil(securityLevel / 8)
66
68
 
67
- let rho = BigInt(0);
68
- do {
69
- let ab = new ArrayBuffer(totalBytes);
70
- let buf = new Uint8Array(ab);
71
- rho = BigInt(hexlify(getRandomValues(buf))) % P;
72
- } while (rho === BigInt(0));
69
+ let rho = BigInt(0)
70
+ do {
71
+ let ab = new ArrayBuffer(totalBytes)
72
+ let buf = new Uint8Array(ab)
73
+ rho = BigInt(hexlify(getRandomValues(buf))) % P
74
+ } while (rho === BigInt(0))
73
75
 
74
- return rho;
76
+ return rho
75
77
  }
76
78
 
77
79
  export function calcNullifier(rho: bigint, fuzkPubKey: [Fr, Fr]): bigint {
78
- return mimc_bn254([rho, BigInt(fuzkPubKey[0].toString()), BigInt(fuzkPubKey[1].toString())]);
80
+ return mimc_bn254([
81
+ rho,
82
+ BigInt(fuzkPubKey[0].toString()),
83
+ BigInt(fuzkPubKey[1].toString()),
84
+ ])
79
85
  }
80
86
 
81
87
  export function createOrderNoteExt(
82
- address: string,
83
- asset: string,
84
- amount: bigint,
85
- feeRatio: bigint,
86
- fuzkPubKey: [Fr, Fr]
88
+ address: string,
89
+ asset: string,
90
+ amount: bigint,
91
+ feeRatio: bigint,
92
+ fuzkPubKey: [Fr, Fr]
87
93
  ): DarkSwapOrderNote {
88
- const rho = generateRho();
89
- const footer = getNoteFooter(rho, fuzkPubKey)
94
+ const rho = generateRho()
95
+ const footer = getNoteFooter(rho, fuzkPubKey)
90
96
 
91
- const assetMod = encodeAddress(asset);
92
- const addressMod = encodeAddress(address);
93
- const noteCommitment = mimc_bn254([
94
- DOMAIN_ORDER_NOTE,
95
- addressMod,
96
- assetMod,
97
- amount,
98
- feeRatio,
99
- footer
100
- ]);
97
+ const assetMod = encodeAddress(asset)
98
+ const addressMod = encodeAddress(address)
99
+ const noteCommitment = mimc_bn254([
100
+ DOMAIN_ORDER_NOTE,
101
+ addressMod,
102
+ assetMod,
103
+ amount,
104
+ feeRatio,
105
+ footer,
106
+ ])
101
107
 
102
- return {
103
- rho,
104
- note: noteCommitment,
105
- asset,
106
- amount,
107
- feeRatio
108
- };
109
- }
108
+ return {
109
+ rho,
110
+ note: noteCommitment,
111
+ asset,
112
+ amount,
113
+ feeRatio,
114
+ }
115
+ }