/// <summary> /// General information extracted from a range proof. /// </summary> /// <returns>The info.</returns> /// <param name="struct">Proof.</param> public ProofInfoStruct Info(ProofStruct @struct) { int exp = 0, mantissa = 0; ulong min = 0, max = 0; byte[] secretKey = new byte[32]; using (var secp256k1 = new Secp256k1()) secretKey = secp256k1.CreatePrivateKey(); var success = secp256k1_rangeproof_info( Context, ref exp, ref mantissa, ref min, ref max, @struct.proof, @struct.plen) == 1; return(new ProofInfoStruct( success, 0, new byte[Constant.PROOF_MSG_SIZE], secretKey, 0, min, max, exp, mantissa)); }
/// <summary> /// /// </summary> /// <param name="sk"></param> /// <param name="pk"></param> /// <returns></returns> public byte[] ToKeyImage(byte[] sk, byte[] pk) { if (pk.Length < Constant.PUBLIC_KEY_COMPRESSED_SIZE) { throw new ArgumentException($"{nameof(pk)} must be {Constant.PUBLIC_KEY_COMPRESSED_SIZE} bytes"); } if (sk.Length != Constant.BLIND_LENGTH) { throw new ArgumentException($"{nameof(sk)} must be {Constant.BLIND_LENGTH} bytes"); } if (pk.Length > Constant.PUBLIC_KEY_SIZE) { throw new ArgumentException($"{nameof(pk)} must be {Constant.PUBLIC_KEY_SIZE} bytes"); } if (pk.Length == Constant.PUBLIC_KEY_SIZE) { using var secp256k1 = new Secp256k1(); pk = secp256k1.SerializePublicKey(pk, Flags.SECP256K1_EC_COMPRESSED); } byte[] keyImage = null; if (pk.Length == Constant.PUBLIC_KEY_COMPRESSED_SIZE) { keyImage = new byte[Constant.PUBLIC_KEY_COMPRESSED_SIZE]; keyImage = secp256k1_get_keyimage(Context, keyImage, pk, sk) == 0 ? keyImage : null; } return(keyImage); }