@gardenfi/utils 2.1.2-beta.11 → 2.1.2-beta.13
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.cjs +1 -1
- package/dist/index.js +20 -21
- package/dist/index100.cjs +1 -1
- package/dist/index100.js +12 -7
- package/dist/index101.cjs +1 -1
- package/dist/index101.js +109 -26
- package/dist/index102.cjs +1 -1
- package/dist/index102.js +8 -10
- package/dist/index103.cjs +1 -1
- package/dist/index103.js +6 -9
- package/dist/index104.cjs +1 -1
- package/dist/index104.js +6 -114
- package/dist/index105.cjs +1 -1
- package/dist/index105.js +21 -80
- package/dist/index106.cjs +1 -1
- package/dist/index106.js +8 -181
- package/dist/index107.cjs +1 -1
- package/dist/index107.js +31 -6
- package/dist/index108.cjs +1 -1
- package/dist/index108.js +13 -13
- package/dist/index109.cjs +1 -1
- package/dist/index109.js +7 -13
- package/dist/index110.cjs +1 -1
- package/dist/index110.js +9 -93
- package/dist/index111.cjs +1 -1
- package/dist/index111.js +16 -75
- package/dist/index112.cjs +1 -1
- package/dist/index112.js +72 -87
- package/dist/index113.cjs +1 -1
- package/dist/index113.js +34 -137
- package/dist/index114.cjs +1 -1
- package/dist/index114.js +45 -68
- package/dist/index115.cjs +1 -1
- package/dist/index115.js +14 -23
- package/dist/index116.cjs +1 -1
- package/dist/index116.js +13 -109
- package/dist/index117.cjs +1 -1
- package/dist/index117.js +9 -6
- package/dist/index118.cjs +1 -1
- package/dist/index118.js +16 -50
- package/dist/index119.cjs +1 -1
- package/dist/index119.js +64 -15
- package/dist/index120.cjs +1 -1
- package/dist/index120.js +11 -10
- package/dist/index121.cjs +1 -1
- package/dist/index121.js +13 -5
- package/dist/index122.cjs +1 -1
- package/dist/index122.js +8 -10
- package/dist/index123.cjs +1 -1
- package/dist/index123.js +10 -3
- package/dist/index124.cjs +1 -1
- package/dist/index124.js +25 -25
- package/dist/index125.cjs +1 -1
- package/dist/index125.js +9 -4
- package/dist/index126.cjs +3 -1
- package/dist/index126.js +110 -6
- package/dist/index127.cjs +1 -1
- package/dist/index127.js +51 -47
- package/dist/index128.cjs +1 -1
- package/dist/index128.js +24 -123
- package/dist/index129.cjs +1 -1
- package/dist/index129.js +115 -7
- package/dist/index130.cjs +20 -1
- package/dist/index130.js +323 -18
- package/dist/index131.cjs +1 -1
- package/dist/index131.js +80 -17
- package/dist/index132.cjs +1 -1
- package/dist/index132.js +30 -40
- package/dist/index133.cjs +4 -1
- package/dist/index133.js +194 -21
- package/dist/index134.cjs +1 -1
- package/dist/index134.js +24 -11
- package/dist/index135.cjs +1 -1
- package/dist/index135.js +181 -6
- package/dist/index136.cjs +1 -1
- package/dist/index136.js +11 -105
- package/dist/index137.cjs +1 -1
- package/dist/index137.js +25 -3
- package/dist/index138.cjs +1 -1
- package/dist/index138.js +3 -4
- package/dist/index139.cjs +1 -1
- package/dist/index139.js +89 -9
- package/dist/index140.cjs +1 -1
- package/dist/index140.js +33 -2
- package/dist/index141.cjs +1 -2
- package/dist/index141.js +16 -3
- package/dist/index142.cjs +1 -20
- package/dist/index142.js +2 -327
- package/dist/index143.cjs +1 -1
- package/dist/index143.js +75 -13
- package/dist/index144.cjs +1 -1
- package/dist/index144.js +138 -4
- package/dist/index145.cjs +3 -1
- package/dist/index145.js +452 -2
- package/dist/index146.cjs +1 -1
- package/dist/index146.js +61 -6
- package/dist/index147.cjs +1 -3
- package/dist/index147.js +6 -215
- package/dist/index148.cjs +1 -1
- package/dist/index148.js +70 -32
- package/dist/index149.cjs +1 -1
- package/dist/index149.js +5 -21
- package/dist/index150.cjs +1 -1
- package/dist/index150.js +3 -5
- package/dist/index151.cjs +1 -1
- package/dist/index151.js +10 -73
- package/dist/index152.cjs +1 -1
- package/dist/index152.js +47 -5
- package/dist/index153.cjs +2 -1
- package/dist/index153.js +24 -5
- package/dist/index154.cjs +1 -9
- package/dist/index154.js +13 -35
- package/dist/index155.cjs +1 -3
- package/dist/index155.js +26 -110
- package/dist/index156.cjs +1 -1
- package/dist/index156.js +8 -3
- package/dist/index157.cjs +1 -1
- package/dist/index157.js +35 -20
- package/dist/index158.cjs +1 -3
- package/dist/index158.js +8 -451
- package/dist/index159.cjs +1 -2
- package/dist/index159.js +9 -54
- package/dist/index160.cjs +1 -1
- package/dist/index160.js +14 -25
- package/dist/index161.cjs +1 -1
- package/dist/index161.js +92 -32
- package/dist/index162.cjs +1 -1
- package/dist/index162.js +20 -35
- package/dist/index163.cjs +1 -4
- package/dist/index163.js +4 -194
- package/dist/index164.cjs +1 -1
- package/dist/index164.js +6 -8
- package/dist/index165.cjs +1 -1
- package/dist/index165.js +26 -18
- package/dist/index166.cjs +1 -1
- package/dist/index166.js +9 -27
- package/dist/index167.cjs +1 -1
- package/dist/index167.js +8 -8
- package/dist/index168.cjs +1 -1
- package/dist/index168.js +10 -7
- package/dist/index169.cjs +1 -1
- package/dist/index169.js +11 -16
- package/dist/index170.cjs +1 -1
- package/dist/index170.js +13 -18
- package/dist/index171.cjs +1 -1
- package/dist/index171.js +14 -21
- package/dist/index172.cjs +1 -1
- package/dist/index172.js +7 -51
- package/dist/index173.cjs +1 -1
- package/dist/index173.js +21 -11
- package/dist/index174.cjs +1 -1
- package/dist/index174.js +6 -161
- package/dist/index175.cjs +1 -1
- package/dist/index175.js +21 -127
- package/dist/index176.cjs +1 -1
- package/dist/index176.js +39 -37
- package/dist/index177.cjs +1 -1
- package/dist/index177.js +17 -6
- package/dist/index178.cjs +1 -1
- package/dist/index178.js +21 -27
- package/dist/index179.cjs +1 -1
- package/dist/index179.js +74 -185
- package/dist/index18.cjs +1 -1
- package/dist/index18.js +8 -8
- package/dist/index180.cjs +1 -1
- package/dist/index180.js +45 -4
- package/dist/index181.cjs +1 -1
- package/dist/index181.js +10 -61
- package/dist/index182.cjs +1 -1
- package/dist/index182.js +53 -3
- package/dist/index183.cjs +1 -1
- package/dist/index183.js +3 -20
- package/dist/index184.cjs +1 -1
- package/dist/index184.js +5 -16
- package/dist/index185.cjs +1 -1
- package/dist/index185.js +5 -23
- package/dist/index186.cjs +1 -1
- package/dist/index186.js +11 -34
- package/dist/index187.cjs +1 -1
- package/dist/index187.js +14 -3
- package/dist/index188.cjs +1 -1
- package/dist/index188.js +13 -18
- package/dist/index189.cjs +1 -1
- package/dist/index189.js +6 -27
- package/dist/index190.cjs +1 -1
- package/dist/index190.js +151 -36
- package/dist/index191.cjs +1 -1
- package/dist/index191.js +35 -10
- package/dist/index192.cjs +1 -1
- package/dist/index192.js +30 -24
- package/dist/index193.cjs +1 -1
- package/dist/index193.js +8 -27
- package/dist/index194.cjs +1 -1
- package/dist/index194.js +66 -63
- package/dist/index195.cjs +1 -1
- package/dist/index195.js +9 -9
- package/dist/index196.cjs +1 -1
- package/dist/index196.js +70 -23
- package/dist/index197.cjs +1 -1
- package/dist/index197.js +19 -24
- package/dist/index198.cjs +1 -1
- package/dist/index198.js +110 -3
- package/dist/index199.cjs +1 -1
- package/dist/index199.js +23 -14
- package/dist/index20.cjs +1 -1
- package/dist/index20.js +2 -2
- package/dist/index200.cjs +1 -1
- package/dist/index200.js +49 -79
- package/dist/index201.cjs +1 -1
- package/dist/index201.js +106 -5
- package/dist/index202.cjs +1 -1
- package/dist/index202.js +9 -24
- package/dist/index203.cjs +1 -1
- package/dist/index203.js +2 -43
- package/dist/index204.cjs +2 -1
- package/dist/index204.js +3 -6
- package/dist/index205.cjs +1 -1
- package/dist/index205.js +13 -11
- package/dist/index206.cjs +1 -1
- package/dist/index206.js +4 -19
- package/dist/index207.cjs +1 -1
- package/dist/index207.js +2 -79
- package/dist/index208.cjs +1 -1
- package/dist/index208.js +32 -2
- package/dist/index209.cjs +1 -1
- package/dist/index209.js +20 -36
- package/dist/index210.cjs +1 -1
- package/dist/index210.js +5 -111
- package/dist/index211.cjs +1 -1
- package/dist/index211.js +5 -49
- package/dist/index212.cjs +1 -1
- package/dist/index212.js +5 -32
- package/dist/index213.cjs +9 -1
- package/dist/index213.js +35 -8
- package/dist/index214.cjs +1 -1
- package/dist/index214.js +3 -7
- package/dist/index215.cjs +1 -1
- package/dist/index215.js +26 -6
- package/dist/index216.cjs +1 -1
- package/dist/index216.js +33 -11
- package/dist/index217.cjs +1 -1
- package/dist/index217.js +34 -9
- package/dist/index218.cjs +1 -1
- package/dist/index218.js +7 -12
- package/dist/index219.cjs +1 -1
- package/dist/index219.js +17 -31
- package/dist/index220.cjs +1 -1
- package/dist/index220.js +28 -5
- package/dist/index221.cjs +1 -1
- package/dist/index221.js +8 -7
- package/dist/index222.cjs +1 -1
- package/dist/index222.js +7 -8
- package/dist/index223.cjs +1 -1
- package/dist/index223.js +18 -20
- package/dist/index224.cjs +1 -1
- package/dist/index224.js +160 -30
- package/dist/index225.cjs +1 -1
- package/dist/index225.js +127 -20
- package/dist/index226.cjs +1 -1
- package/dist/index226.js +38 -3
- package/dist/index227.cjs +1 -1
- package/dist/index227.js +27 -17
- package/dist/index228.cjs +1 -1
- package/dist/index228.js +191 -10
- package/dist/index229.cjs +1 -1
- package/dist/index229.js +4 -22
- package/dist/index23.cjs +1 -1
- package/dist/index23.js +2 -2
- package/dist/index230.cjs +1 -1
- package/dist/index230.js +3 -23
- package/dist/index231.cjs +1 -1
- package/dist/index231.js +20 -5
- package/dist/index232.cjs +1 -1
- package/dist/index232.js +16 -8
- package/dist/index233.cjs +1 -1
- package/dist/index233.js +32 -102
- package/dist/index234.cjs +1 -1
- package/dist/index234.js +3 -113
- package/dist/index235.cjs +1 -1
- package/dist/index235.js +26 -17
- package/dist/index236.cjs +1 -1
- package/dist/index236.js +24 -16
- package/dist/index237.cjs +1 -1
- package/dist/index237.js +28 -10
- package/dist/index238.cjs +1 -1
- package/dist/index238.js +23 -16
- package/dist/index239.cjs +1 -1
- package/dist/index239.js +41 -21
- package/dist/index24.cjs +1 -1
- package/dist/index24.js +5 -5
- package/dist/index240.cjs +1 -1
- package/dist/index240.js +79 -2
- package/dist/index241.cjs +1 -1
- package/dist/index241.js +2 -14
- package/dist/index242.cjs +1 -1
- package/dist/index242.js +37 -12
- package/dist/index243.cjs +1 -1
- package/dist/index243.js +45 -43
- package/dist/index244.cjs +1 -1
- package/dist/index244.js +6 -11
- package/dist/index245.cjs +1 -1
- package/dist/index245.js +6 -7
- package/dist/index246.cjs +1 -1
- package/dist/index246.js +32 -9
- package/dist/index247.cjs +1 -1
- package/dist/index247.js +5 -14
- package/dist/index248.cjs +1 -1
- package/dist/index248.js +8 -14
- package/dist/index249.cjs +1 -1
- package/dist/index249.js +3 -9
- package/dist/index25.cjs +1 -1
- package/dist/index25.js +2 -2
- package/dist/index250.cjs +1 -1
- package/dist/index250.js +17 -30
- package/dist/index251.cjs +1 -1
- package/dist/index251.js +10 -24
- package/dist/index252.cjs +1 -1
- package/dist/index252.js +5 -12
- package/dist/index253.cjs +1 -1
- package/dist/index253.js +8 -24
- package/dist/index254.cjs +1 -2
- package/dist/index254.js +101 -21
- package/dist/index255.cjs +1 -1
- package/dist/index255.js +112 -13
- package/dist/index256.cjs +1 -1
- package/dist/index256.js +18 -15
- package/dist/index257.cjs +1 -1
- package/dist/index257.js +16 -51
- package/dist/index258.cjs +1 -1
- package/dist/index258.js +27 -15
- package/dist/index259.cjs +1 -1
- package/dist/index259.js +36 -221
- package/dist/index26.cjs +1 -1
- package/dist/index26.js +1 -1
- package/dist/index260.cjs +1 -1
- package/dist/index260.js +15 -27
- package/dist/index261.cjs +1 -1
- package/dist/index261.js +221 -36
- package/dist/index262.cjs +1 -2
- package/dist/index262.js +3 -41
- package/dist/index263.cjs +1 -1
- package/dist/index263.js +141 -2
- package/dist/index264.cjs +1 -1
- package/dist/index264.js +155 -5
- package/dist/index265.cjs +1 -1
- package/dist/index265.js +9 -10
- package/dist/index266.cjs +1 -1
- package/dist/index266.js +110 -16
- package/dist/index267.cjs +2 -1
- package/dist/index267.js +134 -8
- package/dist/index268.cjs +2 -1
- package/dist/index268.js +41 -66
- package/dist/index269.cjs +1 -1
- package/dist/index269.js +2 -66
- package/dist/index27.cjs +1 -1
- package/dist/index27.js +1 -1
- package/dist/index270.cjs +1 -1
- package/dist/index270.js +5 -186
- package/dist/index271.cjs +1 -1
- package/dist/index271.js +8 -20
- package/dist/index272.cjs +1 -1
- package/dist/index272.js +17 -40
- package/dist/index273.cjs +1 -1
- package/dist/index273.js +8 -76
- package/dist/index274.cjs +1 -1
- package/dist/index274.js +66 -40
- package/dist/index275.cjs +1 -1
- package/dist/index275.js +64 -15
- package/dist/index276.cjs +1 -1
- package/dist/index276.js +185 -12
- package/dist/index277.cjs +1 -1
- package/dist/index277.js +21 -11
- package/dist/index278.cjs +1 -2
- package/dist/index278.js +42 -18
- package/dist/index279.cjs +1 -1
- package/dist/index279.js +75 -12
- package/dist/index28.cjs +1 -1
- package/dist/index28.js +2 -2
- package/dist/index280.cjs +1 -1
- package/dist/index280.js +40 -11
- package/dist/index281.cjs +1 -1
- package/dist/index281.js +16 -6
- package/dist/index282.cjs +1 -1
- package/dist/index282.js +14 -7
- package/dist/index283.cjs +1 -1
- package/dist/index283.js +11 -25
- package/dist/index284.cjs +2 -1
- package/dist/index284.js +18 -67
- package/dist/index285.cjs +1 -1
- package/dist/index285.js +12 -69
- package/dist/index286.cjs +1 -1
- package/dist/index286.js +11 -34
- package/dist/index287.cjs +1 -1
- package/dist/index287.js +6 -18
- package/dist/index288.cjs +1 -1
- package/dist/index288.js +7 -4
- package/dist/index289.cjs +1 -1
- package/dist/index289.js +23 -137
- package/dist/index29.cjs +1 -1
- package/dist/index29.js +3 -3
- package/dist/index290.cjs +1 -1
- package/dist/index290.js +34 -155
- package/dist/index291.cjs +1 -1
- package/dist/index291.js +18 -9
- package/dist/index292.cjs +1 -1
- package/dist/index292.js +62 -105
- package/dist/index293.cjs +1 -2
- package/dist/index293.js +60 -127
- package/dist/index294.cjs +1 -1
- package/dist/index294.js +17 -10
- package/dist/index295.cjs +1 -1
- package/dist/index295.js +2 -20
- package/dist/index296.cjs +1 -1
- package/dist/index296.js +41 -2
- package/dist/index297.cjs +1 -1
- package/dist/index297.js +641 -39
- package/dist/index298.cjs +1 -1
- package/dist/index298.js +197 -633
- package/dist/index299.cjs +1 -1
- package/dist/index299.js +167 -201
- package/dist/index30.cjs +1 -1
- package/dist/index30.js +2 -2
- package/dist/index300.cjs +1 -1
- package/dist/index300.js +10 -171
- package/dist/index301.cjs +1 -1
- package/dist/index301.js +18 -17
- package/dist/index302.cjs +2 -1
- package/dist/index302.js +66 -68
- package/dist/index303.cjs +1 -2
- package/dist/index303.js +4 -66
- package/dist/index304.cjs +1 -1
- package/dist/index304.js +40 -4
- package/dist/index305.cjs +1 -1
- package/dist/index305.js +7 -40
- package/dist/index306.cjs +1 -1
- package/dist/index306.js +62 -7
- package/dist/index307.cjs +1 -1
- package/dist/index307.js +72 -57
- package/dist/index308.cjs +1 -1
- package/dist/index308.js +4 -78
- package/dist/index309.cjs +1 -1
- package/dist/index309.js +195 -4
- package/dist/index310.cjs +1 -1
- package/dist/index310.js +67 -193
- package/dist/index311.cjs +1 -1
- package/dist/index311.js +3 -3
- package/dist/index314.cjs +1 -1
- package/dist/index314.js +3 -3
- package/dist/index38.cjs +1 -1
- package/dist/index38.js +1 -1
- package/dist/index39.cjs +1 -1
- package/dist/index39.js +1 -1
- package/dist/index41.cjs +1 -1
- package/dist/index41.js +3 -3
- package/dist/index42.cjs +1 -1
- package/dist/index42.js +3 -3
- package/dist/index43.cjs +1 -1
- package/dist/index43.js +2 -2
- package/dist/index44.cjs +1 -1
- package/dist/index44.js +1 -1
- package/dist/index45.cjs +1 -1
- package/dist/index45.js +2 -2
- package/dist/index46.cjs +1 -1
- package/dist/index46.js +12 -12
- package/dist/index47.cjs +1 -1
- package/dist/index47.js +3 -3
- package/dist/index49.cjs +1 -1
- package/dist/index49.js +1 -1
- package/dist/index5.cjs +1 -1
- package/dist/index5.js +19 -47
- package/dist/index50.cjs +1 -1
- package/dist/index50.js +16 -7
- package/dist/index51.cjs +1 -1
- package/dist/index51.js +9 -30
- package/dist/index52.cjs +1 -1
- package/dist/index52.js +18 -29
- package/dist/index53.cjs +1 -1
- package/dist/index53.js +123 -16
- package/dist/index54.cjs +1 -1
- package/dist/index54.js +57 -30
- package/dist/index55.cjs +1 -1
- package/dist/index55.js +22 -43
- package/dist/index56.cjs +1 -1
- package/dist/index56.js +10 -151
- package/dist/index57.cjs +1 -1
- package/dist/index57.js +18 -33
- package/dist/index58.cjs +1 -1
- package/dist/index58.js +6 -38
- package/dist/index59.cjs +1 -2
- package/dist/index59.js +10 -59
- package/dist/index60.cjs +1 -1
- package/dist/index60.js +32 -32
- package/dist/index61.cjs +1 -1
- package/dist/index61.js +16 -15
- package/dist/index62.cjs +1 -1
- package/dist/index62.js +16 -8
- package/dist/index63.cjs +1 -1
- package/dist/index63.js +8 -2
- package/dist/index64.cjs +1 -1
- package/dist/index64.js +33 -26
- package/dist/index65.cjs +1 -1
- package/dist/index65.js +23 -30
- package/dist/index66.cjs +1 -1
- package/dist/index66.js +21 -8
- package/dist/index67.cjs +1 -1
- package/dist/index67.js +56 -66
- package/dist/index68.cjs +1 -1
- package/dist/index68.js +38 -7
- package/dist/index69.cjs +1 -1
- package/dist/index69.js +36 -27
- package/dist/index70.cjs +1 -1
- package/dist/index70.js +158 -67
- package/dist/index71.cjs +1 -1
- package/dist/index71.js +110 -18
- package/dist/index72.cjs +1 -1
- package/dist/index72.js +2 -111
- package/dist/index73.cjs +1 -1
- package/dist/index73.js +4 -61
- package/dist/index74.cjs +2 -1
- package/dist/index74.js +58 -23
- package/dist/index75.cjs +2 -1
- package/dist/index75.js +51 -37
- package/dist/index76.cjs +3 -1
- package/dist/index76.js +213 -35
- package/dist/index77.cjs +1 -1
- package/dist/index77.js +13 -58
- package/dist/index78.cjs +1 -1
- package/dist/index78.js +11 -161
- package/dist/index79.cjs +1 -1
- package/dist/index79.js +24 -40
- package/dist/index80.cjs +1 -1
- package/dist/index80.js +28 -9
- package/dist/index81.cjs +1 -1
- package/dist/index81.js +47 -36
- package/dist/index82.cjs +1 -1
- package/dist/index82.js +19 -9
- package/dist/index83.cjs +1 -1
- package/dist/index83.js +10 -49
- package/dist/index84.cjs +1 -1
- package/dist/index84.js +34 -79
- package/dist/index85.cjs +1 -1
- package/dist/index85.js +9 -41
- package/dist/index86.cjs +1 -1
- package/dist/index86.js +7 -8
- package/dist/index87.cjs +1 -1
- package/dist/index87.js +30 -5
- package/dist/index88.cjs +1 -1
- package/dist/index88.js +36 -17
- package/dist/index89.cjs +1 -1
- package/dist/index89.js +36 -8
- package/dist/index90.cjs +1 -1
- package/dist/index90.js +9 -13
- package/dist/index91.cjs +1 -1
- package/dist/index91.js +29 -7
- package/dist/index92.cjs +1 -1
- package/dist/index92.js +22 -9
- package/dist/index93.cjs +1 -1
- package/dist/index93.js +81 -42
- package/dist/index94.cjs +1 -1
- package/dist/index94.js +50 -13
- package/dist/index95.cjs +1 -1
- package/dist/index95.js +23 -16
- package/dist/index96.cjs +1 -1
- package/dist/index96.js +41 -13
- package/dist/index97.cjs +1 -1
- package/dist/index97.js +17 -6
- package/dist/index98.cjs +1 -1
- package/dist/index98.js +5 -34
- package/dist/index99.cjs +1 -1
- package/dist/index99.js +8 -8
- package/dist/src/lib/digestKey/digestKey.d.ts +4 -2
- package/dist/src/lib/result.d.ts +13 -9
- package/package.json +1 -1
package/dist/index298.js
CHANGED
|
@@ -1,645 +1,209 @@
|
|
|
1
|
-
import { validateBasic as mt, wNAF as gt, pippenger as Et } from "./index300.js";
|
|
2
|
-
import { Field as bt, mod as wt, getMinHashLength as vt, mapHashToField as Bt, invert as xt } from "./index259.js";
|
|
3
|
-
import { bytesToNumberBE as tt, bitMask as St, validateObject as pt, concatBytes as st, aInRange as Q, ensureBytes as V, bytesToHex as ct, hexToBytes as lt, isBytes as at, createHmacDrbg as Rt, memoized as ut, abool as et, inRange as yt, numberToHexUnpadded as nt, numberToBytesBE as dt } from "./index299.js";
|
|
4
1
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
const w = /* @__PURE__ */ BigInt(0), p = /* @__PURE__ */ BigInt(1);
|
|
3
|
+
function b(t) {
|
|
4
|
+
return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
|
|
7
5
|
}
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
a: "field",
|
|
12
|
-
b: "field"
|
|
13
|
-
}, {
|
|
14
|
-
allowedPrivateKeyLengths: "array",
|
|
15
|
-
wrapPrivateKey: "boolean",
|
|
16
|
-
isTorsionFree: "function",
|
|
17
|
-
clearCofactor: "function",
|
|
18
|
-
allowInfinityPoint: "boolean",
|
|
19
|
-
fromBytes: "function",
|
|
20
|
-
toBytes: "function"
|
|
21
|
-
});
|
|
22
|
-
const { endo: t, Fp: E, a: R } = n;
|
|
23
|
-
if (t) {
|
|
24
|
-
if (!E.eql(R, E.ZERO))
|
|
25
|
-
throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");
|
|
26
|
-
if (typeof t != "object" || typeof t.beta != "bigint" || typeof t.splitScalar != "function")
|
|
27
|
-
throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function");
|
|
28
|
-
}
|
|
29
|
-
return Object.freeze({ ...n });
|
|
6
|
+
function h(t) {
|
|
7
|
+
if (!b(t))
|
|
8
|
+
throw new Error("Uint8Array expected");
|
|
30
9
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
10
|
+
function k(t, n) {
|
|
11
|
+
if (typeof n != "boolean")
|
|
12
|
+
throw new Error(t + " boolean expected, got " + n);
|
|
35
13
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
},
|
|
101
|
-
decode(h) {
|
|
102
|
-
const { Err: n } = U;
|
|
103
|
-
if (h[0] & 128)
|
|
104
|
-
throw new n("invalid signature integer: negative");
|
|
105
|
-
if (h[0] === 0 && !(h[1] & 128))
|
|
106
|
-
throw new n("invalid signature integer: unnecessary leading zero");
|
|
107
|
-
return tt(h);
|
|
108
|
-
}
|
|
109
|
-
},
|
|
110
|
-
toSig(h) {
|
|
111
|
-
const { Err: n, _int: t, _tlv: E } = U, R = V("signature", h), { v: q, l: B } = E.decode(48, R);
|
|
112
|
-
if (B.length)
|
|
113
|
-
throw new n("invalid signature: left bytes after parsing");
|
|
114
|
-
const { v: Y, l: S } = E.decode(2, q), { v: L, l: k } = E.decode(2, S);
|
|
115
|
-
if (k.length)
|
|
116
|
-
throw new n("invalid signature: left bytes after parsing");
|
|
117
|
-
return { r: t.decode(Y), s: t.decode(L) };
|
|
118
|
-
},
|
|
119
|
-
hexFromSig(h) {
|
|
120
|
-
const { _tlv: n, _int: t } = U, E = n.encode(2, t.encode(h.r)), R = n.encode(2, t.encode(h.s)), q = E + R;
|
|
121
|
-
return n.encode(48, q);
|
|
122
|
-
}
|
|
123
|
-
}, j = BigInt(0), A = BigInt(1);
|
|
124
|
-
BigInt(2);
|
|
125
|
-
const ht = BigInt(3);
|
|
126
|
-
BigInt(4);
|
|
127
|
-
function Zt(h) {
|
|
128
|
-
const n = Ot(h), { Fp: t } = n, E = bt(n.n, n.nBitLength), R = n.toBytes || ((m, e, s) => {
|
|
129
|
-
const c = e.toAffine();
|
|
130
|
-
return st(Uint8Array.from([4]), t.toBytes(c.x), t.toBytes(c.y));
|
|
131
|
-
}), q = n.fromBytes || ((m) => {
|
|
132
|
-
const e = m.subarray(1), s = t.fromBytes(e.subarray(0, t.BYTES)), c = t.fromBytes(e.subarray(t.BYTES, 2 * t.BYTES));
|
|
133
|
-
return { x: s, y: c };
|
|
134
|
-
});
|
|
135
|
-
function B(m) {
|
|
136
|
-
const { a: e, b: s } = n, c = t.sqr(m), u = t.mul(c, m);
|
|
137
|
-
return t.add(t.add(u, t.mul(m, e)), s);
|
|
138
|
-
}
|
|
139
|
-
if (!t.eql(t.sqr(n.Gy), B(n.Gx)))
|
|
140
|
-
throw new Error("bad generator point: equation left != right");
|
|
141
|
-
function Y(m) {
|
|
142
|
-
return yt(m, A, n.n);
|
|
143
|
-
}
|
|
144
|
-
function S(m) {
|
|
145
|
-
const { allowedPrivateKeyLengths: e, nByteLength: s, wrapPrivateKey: c, n: u } = n;
|
|
146
|
-
if (e && typeof m != "bigint") {
|
|
147
|
-
if (at(m) && (m = ct(m)), typeof m != "string" || !e.includes(m.length))
|
|
148
|
-
throw new Error("invalid private key");
|
|
149
|
-
m = m.padStart(s * 2, "0");
|
|
150
|
-
}
|
|
151
|
-
let p;
|
|
14
|
+
function F(t) {
|
|
15
|
+
const n = t.toString(16);
|
|
16
|
+
return n.length & 1 ? "0" + n : n;
|
|
17
|
+
}
|
|
18
|
+
function E(t) {
|
|
19
|
+
if (typeof t != "string")
|
|
20
|
+
throw new Error("hex string expected, got " + typeof t);
|
|
21
|
+
return t === "" ? w : BigInt("0x" + t);
|
|
22
|
+
}
|
|
23
|
+
const U = (
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function"
|
|
26
|
+
), S = /* @__PURE__ */ Array.from({ length: 256 }, (t, n) => n.toString(16).padStart(2, "0"));
|
|
27
|
+
function x(t) {
|
|
28
|
+
if (h(t), U)
|
|
29
|
+
return t.toHex();
|
|
30
|
+
let n = "";
|
|
31
|
+
for (let e = 0; e < t.length; e++)
|
|
32
|
+
n += S[t[e]];
|
|
33
|
+
return n;
|
|
34
|
+
}
|
|
35
|
+
const u = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
|
36
|
+
function m(t) {
|
|
37
|
+
if (t >= u._0 && t <= u._9)
|
|
38
|
+
return t - u._0;
|
|
39
|
+
if (t >= u.A && t <= u.F)
|
|
40
|
+
return t - (u.A - 10);
|
|
41
|
+
if (t >= u.a && t <= u.f)
|
|
42
|
+
return t - (u.a - 10);
|
|
43
|
+
}
|
|
44
|
+
function B(t) {
|
|
45
|
+
if (typeof t != "string")
|
|
46
|
+
throw new Error("hex string expected, got " + typeof t);
|
|
47
|
+
if (U)
|
|
48
|
+
return Uint8Array.fromHex(t);
|
|
49
|
+
const n = t.length, e = n / 2;
|
|
50
|
+
if (n % 2)
|
|
51
|
+
throw new Error("hex string expected, got unpadded hex of length " + n);
|
|
52
|
+
const r = new Uint8Array(e);
|
|
53
|
+
for (let o = 0, i = 0; o < e; o++, i += 2) {
|
|
54
|
+
const a = m(t.charCodeAt(i)), f = m(t.charCodeAt(i + 1));
|
|
55
|
+
if (a === void 0 || f === void 0) {
|
|
56
|
+
const c = t[i] + t[i + 1];
|
|
57
|
+
throw new Error('hex string expected, got non-hex character "' + c + '" at index ' + i);
|
|
58
|
+
}
|
|
59
|
+
r[o] = a * 16 + f;
|
|
60
|
+
}
|
|
61
|
+
return r;
|
|
62
|
+
}
|
|
63
|
+
function O(t) {
|
|
64
|
+
return E(x(t));
|
|
65
|
+
}
|
|
66
|
+
function V(t) {
|
|
67
|
+
return h(t), E(x(Uint8Array.from(t).reverse()));
|
|
68
|
+
}
|
|
69
|
+
function T(t, n) {
|
|
70
|
+
return B(t.toString(16).padStart(n * 2, "0"));
|
|
71
|
+
}
|
|
72
|
+
function C(t, n) {
|
|
73
|
+
return T(t, n).reverse();
|
|
74
|
+
}
|
|
75
|
+
function M(t, n, e) {
|
|
76
|
+
let r;
|
|
77
|
+
if (typeof n == "string")
|
|
152
78
|
try {
|
|
153
|
-
|
|
154
|
-
} catch {
|
|
155
|
-
throw new Error("
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
if (t.eql(u, t.ONE))
|
|
166
|
-
return { x: s, y: c };
|
|
167
|
-
const p = m.is0();
|
|
168
|
-
e == null && (e = p ? t.ONE : t.inv(u));
|
|
169
|
-
const v = t.mul(s, e), y = t.mul(c, e), a = t.mul(u, e);
|
|
170
|
-
if (p)
|
|
171
|
-
return { x: t.ZERO, y: t.ZERO };
|
|
172
|
-
if (!t.eql(a, t.ONE))
|
|
173
|
-
throw new Error("invZ was invalid");
|
|
174
|
-
return { x: v, y };
|
|
175
|
-
}), rt = ut((m) => {
|
|
176
|
-
if (m.is0()) {
|
|
177
|
-
if (n.allowInfinityPoint && !t.is0(m.py))
|
|
178
|
-
return;
|
|
179
|
-
throw new Error("bad point: ZERO");
|
|
180
|
-
}
|
|
181
|
-
const { x: e, y: s } = m.toAffine();
|
|
182
|
-
if (!t.isValid(e) || !t.isValid(s))
|
|
183
|
-
throw new Error("bad point: x or y not FE");
|
|
184
|
-
const c = t.sqr(s), u = B(e);
|
|
185
|
-
if (!t.eql(c, u))
|
|
186
|
-
throw new Error("bad point: equation left != right");
|
|
187
|
-
if (!m.isTorsionFree())
|
|
188
|
-
throw new Error("bad point: not in prime-order subgroup");
|
|
189
|
-
return !0;
|
|
190
|
-
});
|
|
191
|
-
class w {
|
|
192
|
-
constructor(e, s, c) {
|
|
193
|
-
if (e == null || !t.isValid(e))
|
|
194
|
-
throw new Error("x required");
|
|
195
|
-
if (s == null || !t.isValid(s))
|
|
196
|
-
throw new Error("y required");
|
|
197
|
-
if (c == null || !t.isValid(c))
|
|
198
|
-
throw new Error("z required");
|
|
199
|
-
this.px = e, this.py = s, this.pz = c, Object.freeze(this);
|
|
200
|
-
}
|
|
201
|
-
// Does not validate if the point is on-curve.
|
|
202
|
-
// Use fromHex instead, or call assertValidity() later.
|
|
203
|
-
static fromAffine(e) {
|
|
204
|
-
const { x: s, y: c } = e || {};
|
|
205
|
-
if (!e || !t.isValid(s) || !t.isValid(c))
|
|
206
|
-
throw new Error("invalid affine point");
|
|
207
|
-
if (e instanceof w)
|
|
208
|
-
throw new Error("projective point not allowed");
|
|
209
|
-
const u = (p) => t.eql(p, t.ZERO);
|
|
210
|
-
return u(s) && u(c) ? w.ZERO : new w(s, c, t.ONE);
|
|
211
|
-
}
|
|
212
|
-
get x() {
|
|
213
|
-
return this.toAffine().x;
|
|
214
|
-
}
|
|
215
|
-
get y() {
|
|
216
|
-
return this.toAffine().y;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Takes a bunch of Projective Points but executes only one
|
|
220
|
-
* inversion on all of them. Inversion is very slow operation,
|
|
221
|
-
* so this improves performance massively.
|
|
222
|
-
* Optimization: converts a list of projective points to a list of identical points with Z=1.
|
|
223
|
-
*/
|
|
224
|
-
static normalizeZ(e) {
|
|
225
|
-
const s = t.invertBatch(e.map((c) => c.pz));
|
|
226
|
-
return e.map((c, u) => c.toAffine(s[u])).map(w.fromAffine);
|
|
227
|
-
}
|
|
228
|
-
/**
|
|
229
|
-
* Converts hash string or Uint8Array to Point.
|
|
230
|
-
* @param hex short/long ECDSA hex
|
|
231
|
-
*/
|
|
232
|
-
static fromHex(e) {
|
|
233
|
-
const s = w.fromAffine(q(V("pointHex", e)));
|
|
234
|
-
return s.assertValidity(), s;
|
|
235
|
-
}
|
|
236
|
-
// Multiplies generator point by privateKey.
|
|
237
|
-
static fromPrivateKey(e) {
|
|
238
|
-
return w.BASE.multiply(S(e));
|
|
239
|
-
}
|
|
240
|
-
// Multiscalar Multiplication
|
|
241
|
-
static msm(e, s) {
|
|
242
|
-
return Et(w, E, e, s);
|
|
243
|
-
}
|
|
244
|
-
// "Private method", don't use it directly
|
|
245
|
-
_setWindowSize(e) {
|
|
246
|
-
D.setWindowSize(this, e);
|
|
247
|
-
}
|
|
248
|
-
// A point on curve is valid if it conforms to equation.
|
|
249
|
-
assertValidity() {
|
|
250
|
-
rt(this);
|
|
251
|
-
}
|
|
252
|
-
hasEvenY() {
|
|
253
|
-
const { y: e } = this.toAffine();
|
|
254
|
-
if (t.isOdd)
|
|
255
|
-
return !t.isOdd(e);
|
|
256
|
-
throw new Error("Field doesn't support isOdd");
|
|
257
|
-
}
|
|
258
|
-
/**
|
|
259
|
-
* Compare one point to another.
|
|
260
|
-
*/
|
|
261
|
-
equals(e) {
|
|
262
|
-
L(e);
|
|
263
|
-
const { px: s, py: c, pz: u } = this, { px: p, py: v, pz: y } = e, a = t.eql(t.mul(s, y), t.mul(p, u)), f = t.eql(t.mul(c, y), t.mul(v, u));
|
|
264
|
-
return a && f;
|
|
265
|
-
}
|
|
266
|
-
/**
|
|
267
|
-
* Flips point to one corresponding to (x, -y) in Affine coordinates.
|
|
268
|
-
*/
|
|
269
|
-
negate() {
|
|
270
|
-
return new w(this.px, t.neg(this.py), this.pz);
|
|
271
|
-
}
|
|
272
|
-
// Renes-Costello-Batina exception-free doubling formula.
|
|
273
|
-
// There is 30% faster Jacobian formula, but it is not complete.
|
|
274
|
-
// https://eprint.iacr.org/2015/1060, algorithm 3
|
|
275
|
-
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
276
|
-
double() {
|
|
277
|
-
const { a: e, b: s } = n, c = t.mul(s, ht), { px: u, py: p, pz: v } = this;
|
|
278
|
-
let y = t.ZERO, a = t.ZERO, f = t.ZERO, l = t.mul(u, u), Z = t.mul(p, p), x = t.mul(v, v), b = t.mul(u, p);
|
|
279
|
-
return b = t.add(b, b), f = t.mul(u, v), f = t.add(f, f), y = t.mul(e, f), a = t.mul(c, x), a = t.add(y, a), y = t.sub(Z, a), a = t.add(Z, a), a = t.mul(y, a), y = t.mul(b, y), f = t.mul(c, f), x = t.mul(e, x), b = t.sub(l, x), b = t.mul(e, b), b = t.add(b, f), f = t.add(l, l), l = t.add(f, l), l = t.add(l, x), l = t.mul(l, b), a = t.add(a, l), x = t.mul(p, v), x = t.add(x, x), l = t.mul(x, b), y = t.sub(y, l), f = t.mul(x, Z), f = t.add(f, f), f = t.add(f, f), new w(y, a, f);
|
|
280
|
-
}
|
|
281
|
-
// Renes-Costello-Batina exception-free addition formula.
|
|
282
|
-
// There is 30% faster Jacobian formula, but it is not complete.
|
|
283
|
-
// https://eprint.iacr.org/2015/1060, algorithm 1
|
|
284
|
-
// Cost: 12M + 0S + 3*a + 3*b3 + 23add.
|
|
285
|
-
add(e) {
|
|
286
|
-
L(e);
|
|
287
|
-
const { px: s, py: c, pz: u } = this, { px: p, py: v, pz: y } = e;
|
|
288
|
-
let a = t.ZERO, f = t.ZERO, l = t.ZERO;
|
|
289
|
-
const Z = n.a, x = t.mul(n.b, ht);
|
|
290
|
-
let b = t.mul(s, p), F = t.mul(c, v), r = t.mul(u, y), o = t.add(s, c), i = t.add(p, v);
|
|
291
|
-
o = t.mul(o, i), i = t.add(b, F), o = t.sub(o, i), i = t.add(s, u);
|
|
292
|
-
let d = t.add(p, y);
|
|
293
|
-
return i = t.mul(i, d), d = t.add(b, r), i = t.sub(i, d), d = t.add(c, u), a = t.add(v, y), d = t.mul(d, a), a = t.add(F, r), d = t.sub(d, a), l = t.mul(Z, i), a = t.mul(x, r), l = t.add(a, l), a = t.sub(F, l), l = t.add(F, l), f = t.mul(a, l), F = t.add(b, b), F = t.add(F, b), r = t.mul(Z, r), i = t.mul(x, i), F = t.add(F, r), r = t.sub(b, r), r = t.mul(Z, r), i = t.add(i, r), b = t.mul(F, i), f = t.add(f, b), b = t.mul(d, i), a = t.mul(o, a), a = t.sub(a, b), b = t.mul(o, F), l = t.mul(d, l), l = t.add(l, b), new w(a, f, l);
|
|
294
|
-
}
|
|
295
|
-
subtract(e) {
|
|
296
|
-
return this.add(e.negate());
|
|
297
|
-
}
|
|
298
|
-
is0() {
|
|
299
|
-
return this.equals(w.ZERO);
|
|
300
|
-
}
|
|
301
|
-
wNAF(e) {
|
|
302
|
-
return D.wNAFCached(this, e, w.normalizeZ);
|
|
303
|
-
}
|
|
304
|
-
/**
|
|
305
|
-
* Non-constant-time multiplication. Uses double-and-add algorithm.
|
|
306
|
-
* It's faster, but should only be used when you don't care about
|
|
307
|
-
* an exposed private key e.g. sig verification, which works over *public* keys.
|
|
308
|
-
*/
|
|
309
|
-
multiplyUnsafe(e) {
|
|
310
|
-
const { endo: s, n: c } = n;
|
|
311
|
-
Q("scalar", e, j, c);
|
|
312
|
-
const u = w.ZERO;
|
|
313
|
-
if (e === j)
|
|
314
|
-
return u;
|
|
315
|
-
if (this.is0() || e === A)
|
|
316
|
-
return this;
|
|
317
|
-
if (!s || D.hasPrecomputes(this))
|
|
318
|
-
return D.wNAFCachedUnsafe(this, e, w.normalizeZ);
|
|
319
|
-
let { k1neg: p, k1: v, k2neg: y, k2: a } = s.splitScalar(e), f = u, l = u, Z = this;
|
|
320
|
-
for (; v > j || a > j; )
|
|
321
|
-
v & A && (f = f.add(Z)), a & A && (l = l.add(Z)), Z = Z.double(), v >>= A, a >>= A;
|
|
322
|
-
return p && (f = f.negate()), y && (l = l.negate()), l = new w(t.mul(l.px, s.beta), l.py, l.pz), f.add(l);
|
|
323
|
-
}
|
|
324
|
-
/**
|
|
325
|
-
* Constant time multiplication.
|
|
326
|
-
* Uses wNAF method. Windowed method may be 10% faster,
|
|
327
|
-
* but takes 2x longer to generate and consumes 2x memory.
|
|
328
|
-
* Uses precomputes when available.
|
|
329
|
-
* Uses endomorphism for Koblitz curves.
|
|
330
|
-
* @param scalar by which the point would be multiplied
|
|
331
|
-
* @returns New point
|
|
332
|
-
*/
|
|
333
|
-
multiply(e) {
|
|
334
|
-
const { endo: s, n: c } = n;
|
|
335
|
-
Q("scalar", e, A, c);
|
|
336
|
-
let u, p;
|
|
337
|
-
if (s) {
|
|
338
|
-
const { k1neg: v, k1: y, k2neg: a, k2: f } = s.splitScalar(e);
|
|
339
|
-
let { p: l, f: Z } = this.wNAF(y), { p: x, f: b } = this.wNAF(f);
|
|
340
|
-
l = D.constTimeNegate(v, l), x = D.constTimeNegate(a, x), x = new w(t.mul(x.px, s.beta), x.py, x.pz), u = l.add(x), p = Z.add(b);
|
|
341
|
-
} else {
|
|
342
|
-
const { p: v, f: y } = this.wNAF(e);
|
|
343
|
-
u = v, p = y;
|
|
344
|
-
}
|
|
345
|
-
return w.normalizeZ([u, p])[0];
|
|
346
|
-
}
|
|
347
|
-
/**
|
|
348
|
-
* Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.
|
|
349
|
-
* Not using Strauss-Shamir trick: precomputation tables are faster.
|
|
350
|
-
* The trick could be useful if both P and Q are not G (not in our case).
|
|
351
|
-
* @returns non-zero affine point
|
|
352
|
-
*/
|
|
353
|
-
multiplyAndAddUnsafe(e, s, c) {
|
|
354
|
-
const u = w.BASE, p = (y, a) => a === j || a === A || !y.equals(u) ? y.multiplyUnsafe(a) : y.multiply(a), v = p(this, s).add(p(e, c));
|
|
355
|
-
return v.is0() ? void 0 : v;
|
|
356
|
-
}
|
|
357
|
-
// Converts Projective point to affine (x, y) coordinates.
|
|
358
|
-
// Can accept precomputed Z^-1 - for example, from invertBatch.
|
|
359
|
-
// (x, y, z) ∋ (x=x/z, y=y/z)
|
|
360
|
-
toAffine(e) {
|
|
361
|
-
return k(this, e);
|
|
362
|
-
}
|
|
363
|
-
isTorsionFree() {
|
|
364
|
-
const { h: e, isTorsionFree: s } = n;
|
|
365
|
-
if (e === A)
|
|
366
|
-
return !0;
|
|
367
|
-
if (s)
|
|
368
|
-
return s(w, this);
|
|
369
|
-
throw new Error("isTorsionFree() has not been declared for the elliptic curve");
|
|
370
|
-
}
|
|
371
|
-
clearCofactor() {
|
|
372
|
-
const { h: e, clearCofactor: s } = n;
|
|
373
|
-
return e === A ? this : s ? s(w, this) : this.multiplyUnsafe(n.h);
|
|
374
|
-
}
|
|
375
|
-
toRawBytes(e = !0) {
|
|
376
|
-
return et("isCompressed", e), this.assertValidity(), R(w, this, e);
|
|
377
|
-
}
|
|
378
|
-
toHex(e = !0) {
|
|
379
|
-
return et("isCompressed", e), ct(this.toRawBytes(e));
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
w.BASE = new w(n.Gx, n.Gy, t.ONE), w.ZERO = new w(t.ZERO, t.ONE, t.ZERO);
|
|
383
|
-
const X = n.nBitLength, D = gt(w, n.endo ? Math.ceil(X / 2) : X);
|
|
384
|
-
return {
|
|
385
|
-
CURVE: n,
|
|
386
|
-
ProjectivePoint: w,
|
|
387
|
-
normPrivateKeyToScalar: S,
|
|
388
|
-
weierstrassEquation: B,
|
|
389
|
-
isWithinCurveOrder: Y
|
|
390
|
-
};
|
|
79
|
+
r = B(n);
|
|
80
|
+
} catch (i) {
|
|
81
|
+
throw new Error(t + " must be hex string or Uint8Array, cause: " + i);
|
|
82
|
+
}
|
|
83
|
+
else if (b(n))
|
|
84
|
+
r = Uint8Array.from(n);
|
|
85
|
+
else
|
|
86
|
+
throw new Error(t + " must be hex string or Uint8Array");
|
|
87
|
+
const o = r.length;
|
|
88
|
+
if (typeof e == "number" && o !== e)
|
|
89
|
+
throw new Error(t + " of length " + e + " expected, got " + o);
|
|
90
|
+
return r;
|
|
391
91
|
}
|
|
392
|
-
function
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
}
|
|
92
|
+
function H(...t) {
|
|
93
|
+
let n = 0;
|
|
94
|
+
for (let r = 0; r < t.length; r++) {
|
|
95
|
+
const o = t[r];
|
|
96
|
+
h(o), n += o.length;
|
|
97
|
+
}
|
|
98
|
+
const e = new Uint8Array(n);
|
|
99
|
+
for (let r = 0, o = 0; r < t.length; r++) {
|
|
100
|
+
const i = t[r];
|
|
101
|
+
e.set(i, o), o += i.length;
|
|
102
|
+
}
|
|
103
|
+
return e;
|
|
403
104
|
}
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
}), w = (r) => ct(dt(r, n.nByteLength));
|
|
443
|
-
function X(r) {
|
|
444
|
-
const o = E >> A;
|
|
445
|
-
return r > o;
|
|
446
|
-
}
|
|
447
|
-
function D(r) {
|
|
448
|
-
return X(r) ? B(-r) : r;
|
|
449
|
-
}
|
|
450
|
-
const m = (r, o, i) => tt(r.slice(o, i));
|
|
451
|
-
class e {
|
|
452
|
-
constructor(o, i, d) {
|
|
453
|
-
Q("r", o, A, E), Q("s", i, A, E), this.r = o, this.s = i, d != null && (this.recovery = d), Object.freeze(this);
|
|
454
|
-
}
|
|
455
|
-
// pair (bytes of r, bytes of s)
|
|
456
|
-
static fromCompact(o) {
|
|
457
|
-
const i = n.nByteLength;
|
|
458
|
-
return o = V("compactSignature", o, i * 2), new e(m(o, 0, i), m(o, i, 2 * i));
|
|
459
|
-
}
|
|
460
|
-
// DER encoded ECDSA signature
|
|
461
|
-
// https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script
|
|
462
|
-
static fromDER(o) {
|
|
463
|
-
const { r: i, s: d } = U.toSig(V("DER", o));
|
|
464
|
-
return new e(i, d);
|
|
465
|
-
}
|
|
466
|
-
/**
|
|
467
|
-
* @todo remove
|
|
468
|
-
* @deprecated
|
|
469
|
-
*/
|
|
470
|
-
assertValidity() {
|
|
471
|
-
}
|
|
472
|
-
addRecoveryBit(o) {
|
|
473
|
-
return new e(this.r, this.s, o);
|
|
474
|
-
}
|
|
475
|
-
recoverPublicKey(o) {
|
|
476
|
-
const { r: i, s: d, recovery: g } = this, O = y(V("msgHash", o));
|
|
477
|
-
if (g == null || ![0, 1, 2, 3].includes(g))
|
|
478
|
-
throw new Error("recovery id invalid");
|
|
479
|
-
const z = g === 2 || g === 3 ? i + n.n : i;
|
|
480
|
-
if (z >= t.ORDER)
|
|
481
|
-
throw new Error("recovery id 2 or 3 invalid");
|
|
482
|
-
const N = g & 1 ? "03" : "02", C = S.fromHex(N + w(z)), H = Y(z), T = B(-O * H), M = B(d * H), K = S.BASE.multiplyAndAddUnsafe(C, T, M);
|
|
483
|
-
if (!K)
|
|
484
|
-
throw new Error("point at infinify");
|
|
485
|
-
return K.assertValidity(), K;
|
|
486
|
-
}
|
|
487
|
-
// Signatures should be low-s, to prevent malleability.
|
|
488
|
-
hasHighS() {
|
|
489
|
-
return X(this.s);
|
|
490
|
-
}
|
|
491
|
-
normalizeS() {
|
|
492
|
-
return this.hasHighS() ? new e(this.r, B(-this.s), this.recovery) : this;
|
|
493
|
-
}
|
|
494
|
-
// DER-encoded
|
|
495
|
-
toDERRawBytes() {
|
|
496
|
-
return lt(this.toDERHex());
|
|
497
|
-
}
|
|
498
|
-
toDERHex() {
|
|
499
|
-
return U.hexFromSig({ r: this.r, s: this.s });
|
|
500
|
-
}
|
|
501
|
-
// padded bytes of r, then padded bytes of s
|
|
502
|
-
toCompactRawBytes() {
|
|
503
|
-
return lt(this.toCompactHex());
|
|
504
|
-
}
|
|
505
|
-
toCompactHex() {
|
|
506
|
-
return w(this.r) + w(this.s);
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
const s = {
|
|
510
|
-
isValidPrivateKey(r) {
|
|
511
|
-
try {
|
|
512
|
-
return L(r), !0;
|
|
513
|
-
} catch {
|
|
514
|
-
return !1;
|
|
515
|
-
}
|
|
516
|
-
},
|
|
517
|
-
normPrivateKeyToScalar: L,
|
|
518
|
-
/**
|
|
519
|
-
* Produces cryptographically secure private key from random of size
|
|
520
|
-
* (groupLen + ceil(groupLen / 2)) with modulo bias being negligible.
|
|
521
|
-
*/
|
|
522
|
-
randomPrivateKey: () => {
|
|
523
|
-
const r = vt(n.n);
|
|
524
|
-
return Bt(n.randomBytes(r), n.n);
|
|
525
|
-
},
|
|
526
|
-
/**
|
|
527
|
-
* Creates precompute table for an arbitrary EC point. Makes point "cached".
|
|
528
|
-
* Allows to massively speed-up `point.multiply(scalar)`.
|
|
529
|
-
* @returns cached point
|
|
530
|
-
* @example
|
|
531
|
-
* const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey));
|
|
532
|
-
* fast.multiply(privKey); // much faster ECDH now
|
|
533
|
-
*/
|
|
534
|
-
precompute(r = 8, o = S.BASE) {
|
|
535
|
-
return o._setWindowSize(r), o.multiply(BigInt(3)), o;
|
|
536
|
-
}
|
|
105
|
+
const y = (t) => typeof t == "bigint" && w <= t;
|
|
106
|
+
function I(t, n, e) {
|
|
107
|
+
return y(t) && y(n) && y(e) && n <= t && t < e;
|
|
108
|
+
}
|
|
109
|
+
function R(t, n, e, r) {
|
|
110
|
+
if (!I(n, e, r))
|
|
111
|
+
throw new Error("expected valid " + t + ": " + e + " <= n < " + r + ", got " + n);
|
|
112
|
+
}
|
|
113
|
+
function j(t) {
|
|
114
|
+
let n;
|
|
115
|
+
for (n = 0; t > w; t >>= p, n += 1)
|
|
116
|
+
;
|
|
117
|
+
return n;
|
|
118
|
+
}
|
|
119
|
+
const z = (t) => (p << BigInt(t)) - p, d = (t) => new Uint8Array(t), A = (t) => Uint8Array.from(t);
|
|
120
|
+
function D(t, n, e) {
|
|
121
|
+
if (typeof t != "number" || t < 2)
|
|
122
|
+
throw new Error("hashLen must be a number");
|
|
123
|
+
if (typeof n != "number" || n < 2)
|
|
124
|
+
throw new Error("qByteLen must be a number");
|
|
125
|
+
if (typeof e != "function")
|
|
126
|
+
throw new Error("hmacFn must be a function");
|
|
127
|
+
let r = d(t), o = d(t), i = 0;
|
|
128
|
+
const a = () => {
|
|
129
|
+
r.fill(1), o.fill(0), i = 0;
|
|
130
|
+
}, f = (...s) => e(o, r, ...s), c = (s = d(0)) => {
|
|
131
|
+
o = f(A([0]), s), r = f(), s.length !== 0 && (o = f(A([1]), s), r = f());
|
|
132
|
+
}, v = () => {
|
|
133
|
+
if (i++ >= 1e3)
|
|
134
|
+
throw new Error("drbg: tried 1000 values");
|
|
135
|
+
let s = 0;
|
|
136
|
+
const l = [];
|
|
137
|
+
for (; s < n; ) {
|
|
138
|
+
r = f();
|
|
139
|
+
const g = r.slice();
|
|
140
|
+
l.push(g), s += r.length;
|
|
141
|
+
}
|
|
142
|
+
return H(...l);
|
|
537
143
|
};
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
return
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
if (P === j)
|
|
581
|
-
return;
|
|
582
|
-
const $ = B(it * B(K + P * H));
|
|
583
|
-
if ($ === j)
|
|
584
|
-
return;
|
|
585
|
-
let _ = (J.x === P ? 0 : 2) | Number(J.y & A), G = $;
|
|
586
|
-
return O && X($) && (G = D($), _ ^= 1), new e(P, G, _);
|
|
587
|
-
}
|
|
588
|
-
return { seed: M, k2sig: ot };
|
|
589
|
-
}
|
|
590
|
-
const Z = { lowS: n.lowS, prehash: !1 }, x = { lowS: n.lowS, prehash: !1 };
|
|
591
|
-
function b(r, o, i = Z) {
|
|
592
|
-
const { seed: d, k2sig: g } = l(r, o, i), O = n;
|
|
593
|
-
return Rt(O.hash.outputLen, O.nByteLength, O.hmac)(d, g);
|
|
594
|
-
}
|
|
595
|
-
S.BASE._setWindowSize(8);
|
|
596
|
-
function F(r, o, i, d = x) {
|
|
597
|
-
var _;
|
|
598
|
-
const g = r;
|
|
599
|
-
o = V("msgHash", o), i = V("publicKey", i);
|
|
600
|
-
const { lowS: O, prehash: z, format: N } = d;
|
|
601
|
-
if (ft(d), "strict" in d)
|
|
602
|
-
throw new Error("options.strict was renamed to lowS");
|
|
603
|
-
if (N !== void 0 && N !== "compact" && N !== "der")
|
|
604
|
-
throw new Error("format must be compact or der");
|
|
605
|
-
const C = typeof g == "string" || at(g), H = !C && !N && typeof g == "object" && g !== null && typeof g.r == "bigint" && typeof g.s == "bigint";
|
|
606
|
-
if (!C && !H)
|
|
607
|
-
throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");
|
|
608
|
-
let T, M;
|
|
609
|
-
try {
|
|
610
|
-
if (H && (T = new e(g.r, g.s)), C) {
|
|
611
|
-
try {
|
|
612
|
-
N !== "compact" && (T = e.fromDER(g));
|
|
613
|
-
} catch (G) {
|
|
614
|
-
if (!(G instanceof U.Err))
|
|
615
|
-
throw G;
|
|
616
|
-
}
|
|
617
|
-
!T && N !== "der" && (T = e.fromCompact(g));
|
|
618
|
-
}
|
|
619
|
-
M = S.fromHex(i);
|
|
620
|
-
} catch {
|
|
621
|
-
return !1;
|
|
622
|
-
}
|
|
623
|
-
if (!T || O && T.hasHighS())
|
|
624
|
-
return !1;
|
|
625
|
-
z && (o = n.hash(o));
|
|
626
|
-
const { r: K, s: ot } = T, I = y(o), W = Y(ot), it = B(I * W), J = B(K * W), P = (_ = S.BASE.multiplyAndAddUnsafe(M, it, J)) == null ? void 0 : _.toAffine();
|
|
627
|
-
return P ? B(P.x) === K : !1;
|
|
628
|
-
}
|
|
629
|
-
return {
|
|
630
|
-
CURVE: n,
|
|
631
|
-
getPublicKey: c,
|
|
632
|
-
getSharedSecret: p,
|
|
633
|
-
sign: b,
|
|
634
|
-
verify: F,
|
|
635
|
-
ProjectivePoint: S,
|
|
636
|
-
Signature: e,
|
|
637
|
-
utils: s
|
|
144
|
+
return (s, l) => {
|
|
145
|
+
a(), c(s);
|
|
146
|
+
let g;
|
|
147
|
+
for (; !(g = l(v())); )
|
|
148
|
+
c();
|
|
149
|
+
return a(), g;
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
const _ = {
|
|
153
|
+
bigint: (t) => typeof t == "bigint",
|
|
154
|
+
function: (t) => typeof t == "function",
|
|
155
|
+
boolean: (t) => typeof t == "boolean",
|
|
156
|
+
string: (t) => typeof t == "string",
|
|
157
|
+
stringOrUint8Array: (t) => typeof t == "string" || b(t),
|
|
158
|
+
isSafeInteger: (t) => Number.isSafeInteger(t),
|
|
159
|
+
array: (t) => Array.isArray(t),
|
|
160
|
+
field: (t, n) => n.Fp.isValid(t),
|
|
161
|
+
hash: (t) => typeof t == "function" && Number.isSafeInteger(t.outputLen)
|
|
162
|
+
};
|
|
163
|
+
function P(t, n, e = {}) {
|
|
164
|
+
const r = (o, i, a) => {
|
|
165
|
+
const f = _[i];
|
|
166
|
+
if (typeof f != "function")
|
|
167
|
+
throw new Error("invalid validator function");
|
|
168
|
+
const c = t[o];
|
|
169
|
+
if (!(a && c === void 0) && !f(c, t))
|
|
170
|
+
throw new Error("param " + String(o) + " is invalid. Expected " + i + ", got " + c);
|
|
171
|
+
};
|
|
172
|
+
for (const [o, i] of Object.entries(n))
|
|
173
|
+
r(o, i, !1);
|
|
174
|
+
for (const [o, i] of Object.entries(e))
|
|
175
|
+
r(o, i, !0);
|
|
176
|
+
return t;
|
|
177
|
+
}
|
|
178
|
+
function W(t) {
|
|
179
|
+
const n = /* @__PURE__ */ new WeakMap();
|
|
180
|
+
return (e, ...r) => {
|
|
181
|
+
const o = n.get(e);
|
|
182
|
+
if (o !== void 0)
|
|
183
|
+
return o;
|
|
184
|
+
const i = t(e, ...r);
|
|
185
|
+
return n.set(e, i), i;
|
|
638
186
|
};
|
|
639
187
|
}
|
|
640
188
|
export {
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
189
|
+
R as aInRange,
|
|
190
|
+
k as abool,
|
|
191
|
+
h as abytes,
|
|
192
|
+
j as bitLen,
|
|
193
|
+
z as bitMask,
|
|
194
|
+
x as bytesToHex,
|
|
195
|
+
O as bytesToNumberBE,
|
|
196
|
+
V as bytesToNumberLE,
|
|
197
|
+
H as concatBytes,
|
|
198
|
+
D as createHmacDrbg,
|
|
199
|
+
M as ensureBytes,
|
|
200
|
+
B as hexToBytes,
|
|
201
|
+
E as hexToNumber,
|
|
202
|
+
I as inRange,
|
|
203
|
+
b as isBytes,
|
|
204
|
+
W as memoized,
|
|
205
|
+
T as numberToBytesBE,
|
|
206
|
+
C as numberToBytesLE,
|
|
207
|
+
F as numberToHexUnpadded,
|
|
208
|
+
P as validateObject
|
|
645
209
|
};
|