DeriveJunction.fromBytes constructor

DeriveJunction.fromBytes(
  1. bool hard,
  2. Uint8List junctionId
)

Create a new DeriveJunction from a given byte encoded value.

Implementation

factory DeriveJunction.fromBytes(bool hard, Uint8List junctionId) {
  final bytes = Uint8List(junctionIdLength);
  if (junctionId.length > junctionIdLength) {
    final digest = Blake2bDigest(digestSize: 32);
    digest.update(junctionId, 0, junctionId.length);
    digest.doFinal(bytes, 0);
  } else {
    bytes.setAll(0, junctionId);
  }
  return DeriveJunction(hard, bytes);
}