mirror of
https://github.com/tornadocash/tornado-nova
synced 2024-02-02 14:53:56 +01:00
utxo class init
This commit is contained in:
parent
c9f5d2e512
commit
3e89d53d25
34
src/index.ts
34
src/index.ts
@ -1,36 +1,14 @@
|
||||
|
||||
import BigNumber from "bignumber.js"
|
||||
|
||||
class UTXO {
|
||||
amount: BigNumber;
|
||||
blinding: BigNumber;
|
||||
pubkey: BigNumber;
|
||||
privkey: BigNumber;
|
||||
commitment: BigNumber;
|
||||
treeIndex: Boolean[];
|
||||
nullifier: BigNumber;
|
||||
|
||||
constructor(
|
||||
amount,
|
||||
blinding,
|
||||
pubkey,
|
||||
privkey,
|
||||
commitment,
|
||||
treeIndex,
|
||||
nullifier,
|
||||
) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
class Transaction {
|
||||
inputs: UTXO[];
|
||||
outputs: UTXO[];
|
||||
|
||||
}
|
||||
import { Utxo } from './Utxo'
|
||||
const { bigInt } = require('snarkjs')
|
||||
const crypto = require('crypto')
|
||||
const rbigint = (nbytes = 31) => bigInt.leBuff2int(crypto.randomBytes(nbytes))
|
||||
|
||||
async function main() {
|
||||
const deposit = new UTXO();
|
||||
const zeroUtxo = new Utxo(bigInt(0), rbigint(), rbigint())
|
||||
console.log('zeroUtxo publicKey', zeroUtxo.publicKey())
|
||||
}
|
||||
|
||||
main()
|
||||
|
25
src/utxo.ts
Normal file
25
src/utxo.ts
Normal file
@ -0,0 +1,25 @@
|
||||
|
||||
const Hasher = require('../lib/mimc')
|
||||
const hasher = new Hasher()
|
||||
const { bigInt } = require('snarkjs')
|
||||
|
||||
export class Utxo {
|
||||
amount: bigint;
|
||||
blinding: bigint;
|
||||
privateKey: bigint;
|
||||
|
||||
// commitment: bigint;
|
||||
// treeIndex: Boolean[];
|
||||
// nullifier: bigint;
|
||||
|
||||
constructor(amount?: bigint, blinding?: bigint, privateKey?: bigint) {
|
||||
this.amount = amount || bigInt(0);
|
||||
this.blinding = blinding || bigInt(0);
|
||||
this.privateKey = privateKey || bigInt(0);
|
||||
}
|
||||
|
||||
publicKey() {
|
||||
return hasher.hashArray([this.privateKey])
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user