diff --git a/CHANGELOG.md b/CHANGELOG.md index 0a00358..f561e45 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -24,6 +24,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 sized byte arrays. - `Chain.network_id` - a function to get hold of the Chain's network id. ### 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 - `Bitwise.aes` standard library is removed - the builtin operations are superior. diff --git a/docs/sophia_stdlib.md b/docs/sophia_stdlib.md index b07e4a1..c80dfc8 100644 --- a/docs/sophia_stdlib.md +++ b/docs/sophia_stdlib.md @@ -57,6 +57,12 @@ Address.to_str(a : address) : string Base58 encoded string +#### to_bytes +``` +Address.to_bytes(a : address) : bytes(32) +``` + +The binary representation of the address. #### is_contract ``` @@ -564,14 +570,6 @@ Chain.block_height : int" The height of the current block (i.e. the block in which the current call will be included). -#### to_bytes -``` -Address.to_bytes(a : address) : bytes(32) -``` - -The binary representation of the address. - - ##### bytecode_hash ``` Chain.bytecode_hash : 'c => option(hash) @@ -834,11 +832,14 @@ Hash any object to blake2b #### 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 -the `pubkey` +the `pubkey`. + +Note: before v8 of the compiler, `msg` had type `hash` (i.e. `bytes(32)`). + #### ecverify_secp256k1 ``` diff --git a/src/aeso_ast_infer_types.erl b/src/aeso_ast_infer_types.erl index 12e51f4..afbba6d 100644 --- a/src/aeso_ast_infer_types.erl +++ b/src/aeso_ast_infer_types.erl @@ -775,7 +775,7 @@ global_env() -> %% Crypto/Curve operations CryptoScope = #scope { 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)}, {"ecverify_secp256k1", Fun([Hash, Bytes(20), Bytes(65)], Bool)}, {"ecrecover_secp256k1", Fun([Hash, Bytes(65)], Option(Bytes(20)))}, diff --git a/test/contracts/unapplied_builtins.aes b/test/contracts/unapplied_builtins.aes index 5a8b340..f0be4c9 100644 --- a/test/contracts/unapplied_builtins.aes +++ b/test/contracts/unapplied_builtins.aes @@ -36,7 +36,7 @@ contract UnappliedBuiltins = function map_delete() = Map.delete : (_, m) => _ function map_from_list() = Map.from_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_ecverify_secp256k1() = Crypto.ecverify_secp256k1 function crypto_ecrecover_secp256k1() = Crypto.ecrecover_secp256k1