modifiedPrivateKeyBytes static method

Uint8List modifiedPrivateKeyBytes(
  1. List<int> seed
)

Modifies certain bits of seed so that the result is a valid secret key.

Implementation

static Uint8List modifiedPrivateKeyBytes(List<int> seed) {
  if (seed.length != 32) {
    throw ArgumentError('Seed must be 32 bytes');
  }
  final result = Uint8List.fromList(seed);
  // First 3 bits must be 0
  result[0] &= 0xf8;

  // Bit 254 must be 1
  result[31] |= 0x40;

  // Bit 255 must be 0
  result[31] &= 0x7f;
  return result;
}