Principal.fromPublicKey constructor
Principal.fromPublicKey(
- Uint8List publicKey, [
- IcpWalletType? walletType
Implementation
factory Principal.fromPublicKey(Uint8List publicKey,
[IcpWalletType? walletType]) {
final Uint8List OID =
walletType == IcpWalletType.stoic ? ED25519_OID : SECP256K1_OID;
final Uint8List publicKey_der = wrapDER(publicKey, OID);
final sha224Hash = getSha244Digest(publicKey_der);
final Uint8List principal =
Uint8List.fromList([...sha224Hash, SELF_AUTHENTICATING_SUFFIX]);
return Principal(principal);
}