Numbers & Points
Big Numbers
import { BigNumber, Random } from '@bsv/sdk'
const bn1 = new BigNumber(7)
const bn2 = new BigNumber(4)
const bn3 = bn1.add(bn2)
console.log(bn3.toNumber())
// 11// Generate a BigNumber from 32 random bytes (256 bits, like Bitcoin private keys)
const bn1 = new BigNumber(Random(32))
console.log(bn1.toHex())
// 31af7e86775fbbab9b8618eaad8d9782251cc67ff7366d7f59aee5455119c44f
// Multiply this number by 65536
const bn2 = bn1.muln(65536)
// Printed on the screen, this should be two bytes shfted over in hex
// This amounts to four extra zeroes at the end
console.log(bn2.toHex())
// 31af7e86775fbbab9b8618eaad8d9782251cc67ff7366d7f59aee5455119c44f0000Curves and Points
Point Addition and Multiplication
Last updated
Was this helpful?

