commit static method

Uint8List commit(
  1. BigInt amount,
  2. Uint8List mask
)

Implementation

static Uint8List commit(BigInt amount, Uint8List mask) {
  final ed = VaultKeeper.vault.ed25519;

  // Encode amount as a 32-byte LE scalar.
  final amountBytes = Uint8List(32);
  var a = amount;
  for (var i = 0; i < 32 && a > BigInt.zero; i++) {
    amountBytes[i] = (a & BigInt.from(0xFF)).toInt();
    a >>= 8;
  }

  final amountH = ed.scalarMult(amountBytes, h);
  final maskG = ed.scalarMultBase(mask);
  return ed.pointAdd(amountH, maskG);
}