public string GetBase58() { using (Store.Unlock()) { return(Base58.Convert(Store.Secret, Curve.PublicKeyPrefix)); } }
public string GetBase58() { using (Store.Unlock()) { return(Base58.Convert(Store.Data, Curve.PrivateKeyPrefix)); } }
public string Flatten(IMicheline value) { if (value is MichelineString micheString) { return(micheString.Value); } else if (value is MichelineBytes micheBytes) { if (micheBytes.Value.Length != 21) { return(Hex.Convert(micheBytes.Value)); } var prefix = micheBytes.Value[0] == 0 ? Prefix.tz1 : micheBytes.Value[0] == 1 ? Prefix.tz2 : micheBytes.Value[0] == 2 ? Prefix.tz3 : null; if (prefix == null) { return(Hex.Convert(micheBytes.Value)); } var bytes = micheBytes.Value.GetBytes(1, micheBytes.Value.Length - 1); return(Base58.Convert(bytes, prefix)); } else { throw FormatException(value); } }
public string Flatten(IMicheline value) { if (value is MichelineString micheString) { return(micheString.Value); } else if (value is MichelineBytes micheBytes) { var prefix = micheBytes.Value[0] == 0 && micheBytes.Value.Length == 33 ? Prefix.edpk : micheBytes.Value[0] == 1 && micheBytes.Value.Length == 34 ? Prefix.sppk : micheBytes.Value[0] == 2 && micheBytes.Value.Length == 34 ? Prefix.p2pk : null; if (prefix == null) { return(Hex.Convert(micheBytes.Value)); } var bytes = micheBytes.Value.GetBytes(1, micheBytes.Value.Length - 1); return(Base58.Convert(bytes, prefix)); } else { throw FormatException(value); } }
public static string GetGlobalAddress(IMicheline value) { var bytes = LocalForge.ForgeMicheline(value); var hash = Blake2b.GetDigest(bytes); return(Base58.Convert(hash, Prefix.expr)); }
public string GetKeyHash(IMicheline key) { var optimized = Key.Optimize(Micheline.FromBytes(key.ToBytes())); var packed = new byte[] { 5 }.Concat(LocalForge.ForgeMicheline(optimized)); var hash = Blake2b.GetDigest(packed); return(Base58.Convert(hash, Prefix.expr)); }
public static string GetBlindedAddress(string address, string secret) { var pkh = Base58.Parse(address).GetBytes(3, 20); var key = Hex.Parse(secret); var blind = Blake2b.ComputeHash(20, key, pkh); return(Base58.Convert(blind, Prefix)); }
public static string GetContractAddress(int index) { var hash = new byte[32] { 72, 1, 189, 111, 8, 152, 13, 214, 38, 163, 228, 90, 249, 51, 127, 242, 206, 198, 138, 55, 219, 134, 18, 158, 128, 96, 185, 73, 180, 9, 86, 229 }; var address = Blake2b.GetDigest(hash.Concat(GetBytes(index)).ToArray(), 160); return(Base58.Convert(address, new byte[] { 2, 90, 121 })); }
public string ReadBase58(int length, byte[] prefix) { if (prefix == null) { throw new ArgumentNullException(nameof(prefix)); } else if (prefix.Length == 0) { throw new ArgumentException("Prefix length must be greater than 0", nameof(prefix)); } var b58bytes = ReadBytes(length); return(Base58.Convert(b58bytes, prefix)); }
public string Flatten(IMicheline value) { if (value is MichelineString micheString) { return(micheString.Value); } else if (value is MichelineBytes micheBytes) { if (micheBytes.Value.Length != 4) { return(Hex.Convert(micheBytes.Value)); } return(Base58.Convert(micheBytes.Value, Prefix.Net)); } else { throw FormatException(value); } }
public static string GetManager(JsonElement storage) { if (storage.TryGetProperty("bytes", out var keyBytes) && Hex.TryParse(keyBytes.GetString(), out var bytes)) { if (bytes[0] > 2) { return(null); } var prefix = bytes[0] == 0 ? new byte[] { 6, 161, 159 } : bytes[0] == 1 ? new byte[] { 6, 161, 161 } : new byte[] { 6, 161, 164 }; return(Base58.Convert(bytes.GetBytes(1, bytes.Length - 1), prefix)); } else if (storage.TryGetProperty("string", out var keyStr)) { return(keyStr.GetString()); } return(null); }
public string ToBase58() => Base58.Convert(Bytes, Prefix);
public string Flatten(IMicheline value) { if (value is MichelineString micheString) { return(micheString.Value); } else if (value is MichelineBytes micheBytes) { if (micheBytes.Value.Length < 22) { return(Hex.Convert(micheBytes.Value)); } byte[] prefix; if (micheBytes.Value[0] == 0) { if (micheBytes.Value[1] == 0) { prefix = Prefix.tz1; } else if (micheBytes.Value[1] == 1) { prefix = Prefix.tz2; } else if (micheBytes.Value[1] == 2) { prefix = Prefix.tz3; } else { return(Hex.Convert(micheBytes.Value)); } } else if (micheBytes.Value[0] == 1) { if (micheBytes.Value[21] == 0) { prefix = Prefix.KT1; } else { return(Hex.Convert(micheBytes.Value)); } } else { return(Hex.Convert(micheBytes.Value)); } var bytes = micheBytes.Value[0] == 0 ? micheBytes.Value.GetBytes(2, 20) : micheBytes.Value.GetBytes(1, 20); var address = Base58.Convert(bytes, prefix); var entrypoint = micheBytes.Value.Length > 22 ? Utf8.Convert(micheBytes.Value.GetBytes(22, micheBytes.Value.Length - 22)) : string.Empty; return(entrypoint.Length == 0 ? address : $"{address}%{entrypoint}"); } else { throw FormatException(value); } }