@railgun-community/engine
Advanced tools
Comparing version 6.2.22 to 7.0.0
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.WalletNode = exports.deriveNodes = void 0; | ||
const circomlibjs_1 = require("circomlibjs"); | ||
const utils_1 = require("ethereum-cryptography/utils"); | ||
const poseidon_1 = require("../utils/poseidon"); | ||
const bip32_1 = require("./bip32"); | ||
@@ -81,3 +81,3 @@ const bytes_1 = require("../utils/bytes"); | ||
static getMasterPublicKey(spendingPublicKey, nullifyingKey) { | ||
return (0, circomlibjs_1.poseidon)([...spendingPublicKey, nullifyingKey]); | ||
return (0, poseidon_1.poseidon)([...spendingPublicKey, nullifyingKey]); | ||
} | ||
@@ -92,3 +92,3 @@ async getViewingKeyPair() { | ||
const { privateKey } = await this.getViewingKeyPair(); | ||
return (0, circomlibjs_1.poseidon)([(0, bytes_1.hexToBigInt)((0, utils_1.bytesToHex)(privateKey))]); | ||
return (0, poseidon_1.poseidon)([(0, bytes_1.hexToBigInt)((0, utils_1.bytesToHex)(privateKey))]); | ||
} | ||
@@ -95,0 +95,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.verifyMerkleProof = exports.createDummyMerkleProof = void 0; | ||
const circomlibjs_1 = require("circomlibjs"); | ||
const poseidon_1 = require("../utils/poseidon"); | ||
const merkletree_types_1 = require("../models/merkletree-types"); | ||
@@ -14,3 +14,3 @@ const bytes_1 = require("../utils/bytes"); | ||
for (let level = 0; level < elements.length; level += 1) { | ||
latestHash = (0, circomlibjs_1.poseidon)([latestHash, elements[level]]); | ||
latestHash = (0, poseidon_1.poseidon)([latestHash, elements[level]]); | ||
} | ||
@@ -17,0 +17,0 @@ return { |
@@ -8,4 +8,4 @@ "use strict"; | ||
const bn_js_1 = __importDefault(require("bn.js")); | ||
const circomlibjs_1 = require("circomlibjs"); | ||
const msgpack_lite_1 = __importDefault(require("msgpack-lite")); | ||
const poseidon_1 = require("../utils/poseidon"); | ||
const bytes_1 = require("../utils/bytes"); | ||
@@ -88,3 +88,3 @@ const debugger_1 = __importDefault(require("../debugger/debugger")); | ||
static hashLeftRight(left, right) { | ||
return (0, bytes_1.nToHex)((0, circomlibjs_1.poseidon)([(0, bytes_1.hexToBigInt)(left), (0, bytes_1.hexToBigInt)(right)]), bytes_1.ByteLength.UINT_256); | ||
return (0, poseidon_1.poseidonHex)([left, right]); | ||
} | ||
@@ -91,0 +91,0 @@ getTXIDVersionPrefix() { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getReadableTokenAddress = exports.getTokenDataHash = exports.getTokenDataNFT = exports.getTokenDataERC20 = exports.getTokenDataHashERC20 = exports.getUnshieldTokenHash = exports.getUnshieldTokenData = exports.getUnshieldPreImageNoteHash = exports.getUnshieldEventNoteHash = exports.getNoteHash = exports.formatValue = exports.serializeTokenData = exports.extractTokenHashFromCommitmentPreImageV3 = exports.serializePreImage = exports.assertValidNoteRandom = exports.assertValidNoteToken = exports.ERC721_NOTE_VALUE = void 0; | ||
const circomlibjs_1 = require("circomlibjs"); | ||
const poseidon_1 = require("../utils/poseidon"); | ||
const formatted_types_1 = require("../models/formatted-types"); | ||
@@ -84,3 +84,3 @@ const transaction_constants_1 = require("../models/transaction-constants"); | ||
const tokenHash = (0, exports.getTokenDataHash)(tokenData); | ||
return (0, circomlibjs_1.poseidon)([(0, bytes_1.hexToBigInt)(address), (0, bytes_1.hexToBigInt)(tokenHash), value]); | ||
return (0, poseidon_1.poseidon)([(0, bytes_1.hexToBigInt)(address), (0, bytes_1.hexToBigInt)(tokenHash), value]); | ||
}; | ||
@@ -87,0 +87,0 @@ exports.getNoteHash = getNoteHash; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.ShieldNote = void 0; | ||
const circomlibjs_1 = require("circomlibjs"); | ||
const utils_1 = require("ethereum-cryptography/utils"); | ||
const poseidon_1 = require("../utils/poseidon"); | ||
const utils_2 = require("../utils"); | ||
@@ -35,6 +35,6 @@ const bytes_1 = require("../utils/bytes"); | ||
static getNotePublicKey(masterPublicKey, random) { | ||
return (0, circomlibjs_1.poseidon)([masterPublicKey, (0, bytes_1.hexToBigInt)(random)]); | ||
return (0, poseidon_1.poseidon)([masterPublicKey, (0, bytes_1.hexToBigInt)(random)]); | ||
} | ||
static getShieldNoteHash(notePublicKey, tokenHash, valueAfterFee) { | ||
return (0, circomlibjs_1.poseidon)([notePublicKey, (0, bytes_1.hexToBigInt)(tokenHash), valueAfterFee]); | ||
return (0, poseidon_1.poseidon)([notePublicKey, (0, bytes_1.hexToBigInt)(tokenHash), valueAfterFee]); | ||
} | ||
@@ -41,0 +41,0 @@ static decryptRandom(encryptedBundle, sharedKey) { |
@@ -7,3 +7,3 @@ "use strict"; | ||
exports.TransactNote = void 0; | ||
const circomlibjs_1 = require("circomlibjs"); | ||
const poseidon_1 = require("../utils/poseidon"); | ||
const bech32_1 = require("../key-derivation/bech32"); | ||
@@ -111,3 +111,3 @@ const formatted_types_1 = require("../models/formatted-types"); | ||
getNotePublicKey() { | ||
return (0, circomlibjs_1.poseidon)([this.receiverAddressData.masterPublicKey, (0, bytes_1.hexToBigInt)(this.random)]); | ||
return (0, poseidon_1.poseidon)([this.receiverAddressData.masterPublicKey, (0, bytes_1.hexToBigInt)(this.random)]); | ||
} | ||
@@ -125,3 +125,3 @@ getSenderAddress() { | ||
static getHash(notePublicKey, tokenHash, value) { | ||
return (0, circomlibjs_1.poseidon)([notePublicKey, (0, bytes_1.hexToBigInt)(tokenHash), value]); | ||
return (0, poseidon_1.poseidon)([notePublicKey, (0, bytes_1.hexToBigInt)(tokenHash), value]); | ||
} | ||
@@ -408,3 +408,3 @@ /** | ||
static getNullifier(nullifyingKey, leafIndex) { | ||
return (0, circomlibjs_1.poseidon)([nullifyingKey, BigInt(leafIndex)]); | ||
return (0, poseidon_1.poseidon)([nullifyingKey, BigInt(leafIndex)]); | ||
} | ||
@@ -411,0 +411,0 @@ newProcessingNoteWithValue(value) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getBlindedCommitmentForShieldOrTransact = exports.getBlindedCommitmentForUnshield = void 0; | ||
const circomlibjs_1 = require("circomlibjs"); | ||
const poseidon_1 = require("../utils/poseidon"); | ||
const bytes_1 = require("../utils/bytes"); | ||
@@ -14,3 +14,3 @@ const formatHash = (hash) => { | ||
const getBlindedCommitmentForShieldOrTransact = (commitmentHash, npk, globalTreePosition) => { | ||
const hash = (0, circomlibjs_1.poseidon)([(0, bytes_1.hexToBigInt)(commitmentHash), npk, globalTreePosition]); | ||
const hash = (0, poseidon_1.poseidon)([(0, bytes_1.hexToBigInt)(commitmentHash), npk, globalTreePosition]); | ||
return formatHash(hash); | ||
@@ -17,0 +17,0 @@ }; |
@@ -52,4 +52,4 @@ /// <reference types="node" /> | ||
*/ | ||
static initForWallet(walletSource: string, leveldown: AbstractLevelDOWN, artifactGetter: ArtifactGetter, quickSyncEvents: QuickSyncEvents, quickSyncRailgunTransactionsV2: QuickSyncRailgunTransactionsV2, validateRailgunTxidMerkleroot: MerklerootValidator, getLatestValidatedRailgunTxid: GetLatestValidatedRailgunTxid, engineDebugger: Optional<EngineDebugger>, skipMerkletreeScans?: boolean): RailgunEngine; | ||
static initForPOINode(leveldown: AbstractLevelDOWN, artifactGetter: ArtifactGetter, quickSyncEvents: QuickSyncEvents, quickSyncRailgunTransactionsV2: QuickSyncRailgunTransactionsV2, engineDebugger: Optional<EngineDebugger>): RailgunEngine; | ||
static initForWallet(walletSource: string, leveldown: AbstractLevelDOWN, artifactGetter: ArtifactGetter, quickSyncEvents: QuickSyncEvents, quickSyncRailgunTransactionsV2: QuickSyncRailgunTransactionsV2, validateRailgunTxidMerkleroot: MerklerootValidator, getLatestValidatedRailgunTxid: GetLatestValidatedRailgunTxid, engineDebugger: Optional<EngineDebugger>, skipMerkletreeScans?: boolean): Promise<RailgunEngine>; | ||
static initForPOINode(leveldown: AbstractLevelDOWN, artifactGetter: ArtifactGetter, quickSyncEvents: QuickSyncEvents, quickSyncRailgunTransactionsV2: QuickSyncRailgunTransactionsV2, engineDebugger: Optional<EngineDebugger>): Promise<RailgunEngine>; | ||
static setEngineDebugger: (engineDebugger: EngineDebugger) => void; | ||
@@ -56,0 +56,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.calculateRailgunTransactionVerificationHash = exports.createRailgunTransactionWithHash = exports.getRailgunTxidLeafHash = exports.getRailgunTransactionIDHex = exports.getRailgunTransactionIDFromBigInts = exports.getRailgunTransactionID = void 0; | ||
const circomlibjs_1 = require("circomlibjs"); | ||
const poseidon_1 = require("../utils/poseidon"); | ||
const bytes_1 = require("../utils/bytes"); | ||
@@ -26,7 +26,7 @@ const merkletree_types_1 = require("../models/merkletree-types"); | ||
const nullifiersPadded = padWithZerosToMax(nullifiers, maxInputs); | ||
const nullifiersHash = (0, circomlibjs_1.poseidon)(nullifiersPadded); | ||
const nullifiersHash = (0, poseidon_1.poseidon)(nullifiersPadded); | ||
const maxOutputs = 13; // Always 13 - no matter the POI circuit | ||
const commitmentsPadded = padWithZerosToMax(commitments, maxOutputs); | ||
const commitmentsHash = (0, circomlibjs_1.poseidon)(commitmentsPadded); | ||
return (0, circomlibjs_1.poseidon)([nullifiersHash, commitmentsHash, boundParamsHash]); | ||
const commitmentsHash = (0, poseidon_1.poseidon)(commitmentsPadded); | ||
return (0, poseidon_1.poseidon)([nullifiersHash, commitmentsHash, boundParamsHash]); | ||
}; | ||
@@ -40,3 +40,3 @@ exports.getRailgunTransactionIDFromBigInts = getRailgunTransactionIDFromBigInts; | ||
const getRailgunTxidLeafHash = (railgunTxidBigInt, utxoTreeIn, globalTreePosition) => { | ||
return (0, bytes_1.nToHex)((0, circomlibjs_1.poseidon)([railgunTxidBigInt, utxoTreeIn, globalTreePosition]), bytes_1.ByteLength.UINT_256); | ||
return (0, bytes_1.nToHex)((0, poseidon_1.poseidon)([railgunTxidBigInt, utxoTreeIn, globalTreePosition]), bytes_1.ByteLength.UINT_256); | ||
}; | ||
@@ -43,0 +43,0 @@ exports.getRailgunTxidLeafHash = getRailgunTxidLeafHash; |
@@ -67,3 +67,2 @@ "use strict"; | ||
try { | ||
await scalar_multiply_1.initCurve25519Promise; | ||
// Retrieve private scalar from private key | ||
@@ -70,0 +69,0 @@ const scalar = await (0, keys_utils_1.getPrivateScalarFromPrivateKey)(privateKeyPairA); |
@@ -6,2 +6,3 @@ "use strict"; | ||
const circomlibjs_1 = require("circomlibjs"); | ||
const poseidon_1 = require("./poseidon"); | ||
const bytes_1 = require("./bytes"); | ||
@@ -22,3 +23,3 @@ const hash_1 = require("./hash"); | ||
function getRandomScalar() { | ||
return (0, circomlibjs_1.poseidon)([BigInt((0, bytes_1.hexlify)(randomBytes(32), true))]); | ||
return (0, bytes_1.hexToBigInt)((0, poseidon_1.poseidonHex)([(0, bytes_1.fastBytesToHex)(randomBytes(32))])); | ||
} | ||
@@ -157,3 +158,2 @@ exports.getRandomScalar = getRandomScalar; | ||
try { | ||
await scalar_multiply_1.initCurve25519Promise; | ||
// Retrieve private scalar from private key | ||
@@ -160,0 +160,0 @@ const scalar = await getPrivateScalarFromPrivateKey(privateKeyPairA); |
@@ -5,3 +5,3 @@ "use strict"; | ||
const ethers_1 = require("ethers"); | ||
const circomlibjs_1 = require("circomlibjs"); | ||
const poseidon_1 = require("../utils/poseidon"); | ||
const wallet_node_1 = require("../key-derivation/wallet-node"); | ||
@@ -26,3 +26,3 @@ const bytes_1 = require("../utils/bytes"); | ||
const entries = Object.values(publicInputs).flatMap((x) => x); | ||
const msg = (0, circomlibjs_1.poseidon)(entries); | ||
const msg = (0, poseidon_1.poseidon)(entries); | ||
return (0, keys_utils_1.signEDDSA)(spendingKeyPair.privateKey, msg); | ||
@@ -29,0 +29,0 @@ } |
{ | ||
"name": "@railgun-community/engine", | ||
"version": "6.2.22", | ||
"version": "7.0.0", | ||
"description": "Wallet framework for RAILGUN smart contracts and private balances on Ethereum and more.", | ||
@@ -46,2 +46,3 @@ "author": "RAILGUN Contributors", | ||
"@railgun-community/curve25519-scalarmult-wasm": "0.1.5", | ||
"@railgun-community/poseidon-hash-wasm": "1.0.0", | ||
"@scure/base": "^1.1.1", | ||
@@ -99,4 +100,5 @@ "abstract-leveldown": "^7.2.0", | ||
"@railgun-community/curve25519-scalarmult-wasm": false, | ||
"@railgun-community/poseidon-hash-wasm": false, | ||
"crypto": false | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2752357
416
52067
18
+ Added@railgun-community/poseidon-hash-wasm@1.0.0(transitive)