Allow arbitrary sized msg in signature verification

This commit is contained in:
Hans Svensson 2023-08-08 15:55:43 +02:00
parent 8668fd053e
commit 51c523d6b0
4 changed files with 9 additions and 4 deletions

View File

@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
sized byte arrays. sized byte arrays.
- `Chain.network_id` - a function to get hold of the Chain's network id. - `Chain.network_id` - a function to get hold of the Chain's network id.
### Changed ### Changed
- `Crypto.verify_sig` is changed to have `msg : bytes()`. I.e. the
signed data can be of any length (used to be limited to `bytes(32)`/`hash`).
### Removed ### Removed
- `Bitwise.aes` standard library is removed - the builtin operations are superior. - `Bitwise.aes` standard library is removed - the builtin operations are superior.

View File

@ -834,11 +834,14 @@ Hash any object to blake2b
#### verify_sig #### verify_sig
``` ```
Crypto.verify_sig(msg : hash, pubkey : address, sig : signature) : bool Crypto.verify_sig(msg : bytes(), pubkey : address, sig : signature) : bool
``` ```
Checks if the signature of `msg` was made using private key corresponding to Checks if the signature of `msg` was made using private key corresponding to
the `pubkey` the `pubkey`.
Note: before v8 of the compiler, `msg` had type `hash` (i.e. `bytes(32)`).
#### ecverify_secp256k1 #### ecverify_secp256k1
``` ```

View File

@ -775,7 +775,7 @@ global_env() ->
%% Crypto/Curve operations %% Crypto/Curve operations
CryptoScope = #scope CryptoScope = #scope
{ funs = MkDefs( { funs = MkDefs(
[{"verify_sig", Fun([Hash, Address, SignId], Bool)}, [{"verify_sig", Fun([Bytes('_'), Address, SignId], Bool)},
{"verify_sig_secp256k1", Fun([Hash, Bytes(64), SignId], Bool)}, {"verify_sig_secp256k1", Fun([Hash, Bytes(64), SignId], Bool)},
{"ecverify_secp256k1", Fun([Hash, Bytes(20), Bytes(65)], Bool)}, {"ecverify_secp256k1", Fun([Hash, Bytes(20), Bytes(65)], Bool)},
{"ecrecover_secp256k1", Fun([Hash, Bytes(65)], Option(Bytes(20)))}, {"ecrecover_secp256k1", Fun([Hash, Bytes(65)], Option(Bytes(20)))},

View File

@ -36,7 +36,7 @@ contract UnappliedBuiltins =
function map_delete() = Map.delete : (_, m) => _ function map_delete() = Map.delete : (_, m) => _
function map_from_list() = Map.from_list : _ => m function map_from_list() = Map.from_list : _ => m
function map_to_list() = Map.to_list : m => _ function map_to_list() = Map.to_list : m => _
function crypto_verify_sig() = Crypto.verify_sig function crypto_verify_sig() = Crypto.verify_sig : (bytes(), _, _) => _
function crypto_verify_sig_secp256k1() = Crypto.verify_sig_secp256k1 function crypto_verify_sig_secp256k1() = Crypto.verify_sig_secp256k1
function crypto_ecverify_secp256k1() = Crypto.ecverify_secp256k1 function crypto_ecverify_secp256k1() = Crypto.ecverify_secp256k1
function crypto_ecrecover_secp256k1() = Crypto.ecrecover_secp256k1 function crypto_ecrecover_secp256k1() = Crypto.ecrecover_secp256k1