[Ceres] Allow arbitrary sized message in Crypto.verify_sig (#481)

* Allow arbitrary sized msg in signature verification

* Move Address.to_bytes documentation to correct place
This commit is contained in:
Hans Svensson 2023-08-24 16:14:40 +02:00 committed by GitHub
parent 8668fd053e
commit 8f508383e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 12 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

@ -57,6 +57,12 @@ Address.to_str(a : address) : string
Base58 encoded string Base58 encoded string
#### to_bytes
```
Address.to_bytes(a : address) : bytes(32)
```
The binary representation of the address.
#### is_contract #### 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). 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 ##### bytecode_hash
``` ```
Chain.bytecode_hash : 'c => option(hash) Chain.bytecode_hash : 'c => option(hash)
@ -834,11 +832,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