Wire crypto provider into transaction, wallet, and scanning code
Switch 16 consumer files from direct crypto imports to the switchable
crypto provider. setCryptoBackend('wasm') now accelerates all real
transaction building, output scanning, and key derivation end-to-end.
Source implementation files (keccak.js, ed25519.js, scanning.js, etc.)
keep direct imports to avoid circular dependencies.
This commit is contained in:
+1
-1
@@ -9,7 +9,7 @@
|
||||
*/
|
||||
|
||||
import { BASE58_ALPHABET, BASE58_FULL_BLOCK_SIZE, BASE58_FULL_ENCODED_BLOCK_SIZE, BASE58_ENCODED_BLOCK_SIZES } from './constants.js';
|
||||
import { keccak256 } from './keccak.js';
|
||||
import { keccak256 } from './crypto/index.js';
|
||||
|
||||
// Build reverse alphabet lookup
|
||||
const ALPHABET_MAP = new Map();
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
import { ed25519, ed25519_hasher } from '@noble/curves/ed25519.js';
|
||||
import { mod, invert, Field } from '@noble/curves/abstract/modular.js';
|
||||
import { keccak256 } from './keccak.js';
|
||||
import { keccak256 } from './crypto/index.js';
|
||||
|
||||
// Ed25519 curve order (L)
|
||||
const L = BigInt('0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed');
|
||||
|
||||
@@ -15,10 +15,9 @@
|
||||
* - Salvium carrot_core/enote_utils.cpp
|
||||
*/
|
||||
|
||||
import { blake2b } from './blake2b.js';
|
||||
import { keccak256 } from './keccak.js';
|
||||
import { hexToBytes, bytesToHex } from './address.js';
|
||||
import { scalarMultPoint, pointFromBytes, pointToBytes } from './ed25519.js';
|
||||
import { pointFromBytes, pointToBytes } from './ed25519.js';
|
||||
import { blake2b, keccak256, scalarMultPoint } from './crypto/index.js';
|
||||
|
||||
// Group order L for scalar reduction
|
||||
const L = (1n << 252n) + 27742317777372353535851937790883648493n;
|
||||
@@ -698,8 +697,7 @@ export function scanCarrotOutput(output, viewIncomingKey, accountSpendPubkey, in
|
||||
// Import additional ed25519 functions
|
||||
// ============================================================================
|
||||
|
||||
import { scalarMultBase, pointAddCompressed } from './ed25519.js';
|
||||
import { hashToPoint } from './keyimage.js';
|
||||
import { scalarMultBase, pointAddCompressed, hashToPoint } from './crypto/index.js';
|
||||
|
||||
// Group order L for scalar reduction (also defined at top for clarity)
|
||||
const L_ORDER = (1n << 252n) + 27742317777372353535851937790883648493n;
|
||||
|
||||
+2
-3
@@ -3,10 +3,9 @@
|
||||
* Implements key derivation as per Salvium specification
|
||||
*/
|
||||
|
||||
import { blake2b } from './blake2b.js';
|
||||
import { keccak256 } from './keccak.js';
|
||||
import { hexToBytes, bytesToHex } from './address.js';
|
||||
import { scalarMultBase, computeCarrotSpendPubkey, computeCarrotMainAddressViewPubkey, computeCarrotAccountViewPubkey } from './ed25519.js';
|
||||
import { computeCarrotSpendPubkey, computeCarrotMainAddressViewPubkey, computeCarrotAccountViewPubkey } from './ed25519.js';
|
||||
import { blake2b, keccak256, scalarMultBase } from './crypto/index.js';
|
||||
|
||||
// Group order L for scalar reduction
|
||||
const L = (1n << 252n) + 27742317777372353535851937790883648493n;
|
||||
|
||||
+2
-1
@@ -8,7 +8,8 @@
|
||||
* Reference: cryptonote_basic/miner.cpp, cryptonote_basic/difficulty.cpp
|
||||
*/
|
||||
|
||||
import { keccak256, cnFastHash } from './keccak.js';
|
||||
import { cnFastHash } from './keccak.js';
|
||||
import { keccak256 } from './crypto/index.js';
|
||||
import { encodeVarint, serializeBlockHeader, HF_VERSION_ENABLE_ORACLE } from './transaction.js';
|
||||
|
||||
// =============================================================================
|
||||
|
||||
@@ -13,9 +13,8 @@
|
||||
*/
|
||||
|
||||
import { bytesToHex, hexToBytes } from './address.js';
|
||||
import { keccak256 } from './keccak.js';
|
||||
import { scalarMultBase, scalarMultPoint, pointAddCompressed } from './ed25519.js';
|
||||
import { computeCarrotSpendPubkey, computeCarrotMainAddressViewPubkey, computeCarrotAccountViewPubkey } from './ed25519.js';
|
||||
import { keccak256, scalarMultBase, scalarMultPoint, pointAddCompressed } from './crypto/index.js';
|
||||
import { scAdd } from './transaction.js';
|
||||
import { MultisigAccount } from './multisig.js';
|
||||
import {
|
||||
|
||||
+2
-2
@@ -18,8 +18,8 @@
|
||||
*/
|
||||
|
||||
import { bytesToHex, hexToBytes } from './address.js';
|
||||
import { keccak256 } from './keccak.js';
|
||||
import { scalarMultBase, scalarMultPoint, pointAddCompressed, randomScalar } from './ed25519.js';
|
||||
import { randomScalar } from './ed25519.js';
|
||||
import { keccak256, scalarMultBase, scalarMultPoint, pointAddCompressed } from './crypto/index.js';
|
||||
import { scReduce32, scAdd, scMul, scMulAdd } from './transaction.js';
|
||||
import { encode as base58Encode, decode as base58Decode } from './base58.js';
|
||||
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
|
||||
import { bytesToHex, hexToBytes } from './address.js';
|
||||
import { keccak256 } from './keccak.js';
|
||||
import { keccak256 } from './crypto/index.js';
|
||||
import {
|
||||
signTransaction,
|
||||
serializeTransaction,
|
||||
|
||||
+1
-1
@@ -10,7 +10,7 @@
|
||||
* V2: hash = Keccak256(domain_separator + spend_key + view_key + mode + varint(len) + message)
|
||||
*/
|
||||
|
||||
import { keccak256 } from './keccak.js';
|
||||
import { keccak256 } from './crypto/index.js';
|
||||
import { decode } from './base58.js';
|
||||
import { parseAddress } from './address.js';
|
||||
import {
|
||||
|
||||
+3
-6
@@ -5,13 +5,10 @@
|
||||
* plus integrated address creation.
|
||||
*/
|
||||
|
||||
import { keccak256 } from './keccak.js';
|
||||
import { blake2b } from './blake2b.js';
|
||||
import {
|
||||
scalarMultBase,
|
||||
scalarMultPoint,
|
||||
pointAddCompressed
|
||||
} from './ed25519.js';
|
||||
keccak256, blake2b,
|
||||
scalarMultBase, scalarMultPoint, pointAddCompressed,
|
||||
} from './crypto/index.js';
|
||||
|
||||
// Group order L for scalar reduction
|
||||
const L = (1n << 252n) + 27742317777372353535851937790883648493n;
|
||||
|
||||
@@ -15,7 +15,7 @@ import { MemoryStorage } from '../wallet-store.js';
|
||||
import { WalletSync } from '../wallet-sync.js';
|
||||
import { NETWORK_ID, CRYPTONOTE_MINED_MONEY_UNLOCK_WINDOW } from '../consensus.js';
|
||||
import { generateSeed, deriveKeys, deriveCarrotKeys } from '../carrot.js';
|
||||
import { generateKeyDerivation, deriveSecretKey } from '../scanning.js';
|
||||
import { generateKeyDerivation, deriveSecretKey } from '../crypto/index.js';
|
||||
import { selectUTXOs } from '../transaction/utxo.js';
|
||||
import {
|
||||
buildTransaction,
|
||||
|
||||
@@ -11,8 +11,9 @@
|
||||
* @module testnet/miner-tx
|
||||
*/
|
||||
|
||||
import { randomScalar, scalarMultBase } from '../ed25519.js';
|
||||
import { generateKeyDerivation, derivePublicKey, deriveViewTag } from '../scanning.js';
|
||||
import { randomScalar } from '../ed25519.js';
|
||||
import { deriveViewTag } from '../scanning.js';
|
||||
import { scalarMultBase, generateKeyDerivation, derivePublicKey } from '../crypto/index.js';
|
||||
import { cnFastHash } from '../keccak.js';
|
||||
import { serializeTxPrefix, encodeVarint } from '../transaction/serialization.js';
|
||||
import { bytesToHex, hexToBytes } from '../address.js';
|
||||
|
||||
+8
-4
@@ -10,10 +10,14 @@
|
||||
* Reference: Salvium/Monero src/ringct/rctOps.cpp, src/ringct/rctSigs.cpp
|
||||
*/
|
||||
|
||||
import { keccak256, keccak256Hex } from './keccak.js';
|
||||
import { scalarMultBase, scalarMultPoint, pointAddCompressed, getGeneratorG, getGeneratorT } from './ed25519.js';
|
||||
import { generateKeyDerivation, derivationToScalar, derivePublicKey, deriveSecretKey } from './scanning.js';
|
||||
import { hashToPoint, generateKeyImage } from './keyimage.js';
|
||||
import { keccak256Hex } from './keccak.js';
|
||||
import { getGeneratorG, getGeneratorT } from './ed25519.js';
|
||||
import { derivationToScalar } from './scanning.js';
|
||||
import {
|
||||
keccak256, scalarMultBase, scalarMultPoint, pointAddCompressed,
|
||||
generateKeyDerivation, derivePublicKey, deriveSecretKey,
|
||||
hashToPoint, generateKeyImage,
|
||||
} from './crypto/index.js';
|
||||
import { bytesToHex, hexToBytes } from './address.js';
|
||||
|
||||
// =============================================================================
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
* @module transaction/analysis
|
||||
*/
|
||||
|
||||
import { keccak256 } from '../keccak.js';
|
||||
import { keccak256 } from '../crypto/index.js';
|
||||
import { hexToBytes } from '../address.js';
|
||||
|
||||
import { TXIN_TYPE } from './constants.js';
|
||||
|
||||
@@ -14,13 +14,16 @@
|
||||
* @module transaction/carrot-output
|
||||
*/
|
||||
|
||||
import { blake2b } from '../blake2b.js';
|
||||
import { hexToBytes, bytesToHex } from '../address.js';
|
||||
import { scalarMultBase, scalarMultPoint, pointAddCompressed, getGeneratorT } from '../ed25519.js';
|
||||
import { getGeneratorT } from '../ed25519.js';
|
||||
import { edwardsToMontgomeryU, x25519ScalarMult } from '../carrot-scanning.js';
|
||||
import {
|
||||
blake2b, scalarMultBase, scalarMultPoint, pointAddCompressed,
|
||||
scReduce32, commit,
|
||||
} from '../crypto/index.js';
|
||||
|
||||
import { CARROT_DOMAIN, CARROT_ENOTE_TYPE } from './constants.js';
|
||||
import { scReduce32, bigIntToBytes, commit } from './serialization.js';
|
||||
import { bigIntToBytes } from './serialization.js';
|
||||
|
||||
// =============================================================================
|
||||
// CARROT HASH FUNCTIONS
|
||||
|
||||
+4
-5
@@ -12,9 +12,6 @@
|
||||
|
||||
import { WalletOutput, WalletTransaction } from './wallet-store.js';
|
||||
import {
|
||||
generateKeyDerivation,
|
||||
derivePublicKey,
|
||||
deriveSecretKey,
|
||||
deriveViewTag,
|
||||
computeSharedSecret,
|
||||
ecdhDecodeFull,
|
||||
@@ -23,11 +20,13 @@ import {
|
||||
} from './scanning.js';
|
||||
import { cnSubaddressSecretKey, carrotIndexExtensionGenerator, carrotSubaddressScalar } from './subaddress.js';
|
||||
import { scanCarrotOutput, makeInputContext, makeInputContextCoinbase, generateCarrotKeyImage } from './carrot-scanning.js';
|
||||
import { generateKeyImage } from './keyimage.js';
|
||||
import { parseTransaction, extractTxPubKey, extractPaymentId } from './transaction.js';
|
||||
import { bytesToHex, hexToBytes } from './address.js';
|
||||
import { TX_TYPE } from './wallet.js';
|
||||
import { commit as pedersonCommit } from './transaction/serialization.js';
|
||||
import {
|
||||
generateKeyDerivation, derivePublicKey, deriveSecretKey,
|
||||
generateKeyImage, commit as pedersonCommit,
|
||||
} from './crypto/index.js';
|
||||
|
||||
// ============================================================================
|
||||
// CONSTANTS
|
||||
|
||||
+2
-3
@@ -19,8 +19,8 @@
|
||||
import { generateSeed, deriveKeys, deriveCarrotKeys } from './carrot.js';
|
||||
import { createAddress, parseAddress, hexToBytes, bytesToHex } from './address.js';
|
||||
import { cnSubaddress } from './subaddress.js';
|
||||
import { generateKeyDerivation, derivationToScalar, deriveSecretKey, scanTransaction } from './scanning.js';
|
||||
import { generateKeyImage } from './keyimage.js';
|
||||
import { derivationToScalar, scanTransaction } from './scanning.js';
|
||||
import { generateKeyDerivation, deriveSecretKey, generateKeyImage, scalarMultBase } from './crypto/index.js';
|
||||
import {
|
||||
buildTransaction,
|
||||
buildStakeTransaction,
|
||||
@@ -259,7 +259,6 @@ export class Wallet {
|
||||
: spendPublicKey;
|
||||
|
||||
// Derive view public key from view secret key
|
||||
const { scalarMultBase } = require('./ed25519.js');
|
||||
wallet._viewPublicKey = scalarMultBase(wallet._viewSecretKey);
|
||||
|
||||
return wallet;
|
||||
|
||||
Reference in New Issue
Block a user