Skip to content

Commit

Permalink
Add Secp256k1 signature algorithm (#3303)
Browse files Browse the repository at this point in the history
## Motivation

We want to make Linera block headers verifiable on Ethereum and ed25519
is not natively supported in EVM (no precompile).

## Proposal

Add Secp256k1 signature scheme.

In follow-up PRs I'll make use of it.

Note that I've moved signature schemes to their own files.

## Test Plan

Added a unit test for signing & verifying of the `TestString`.

## Release Plan

- Nothing to do / These changes follow the usual release cycle.
## Links

- [reviewer
checklist](https://github.com/linera-io/linera-protocol/blob/main/CONTRIBUTING.md#reviewer-checklist)
  • Loading branch information
deuszx authored Feb 17, 2025
1 parent 2b6a445 commit 7ba6ce5
Show file tree
Hide file tree
Showing 49 changed files with 851 additions and 676 deletions.
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ reqwest = { version = "0.11.24", default-features = false, features = [
"rustls-tls",
] }
rocksdb = "0.21.0"
secp256k1 = { version = "0.30.0", default-features = false, features = [ "alloc", "rand", "serde" ] }
scylla = "0.15.1"
semver = "1.0.22"
serde = { version = "1.0.197", features = ["derive"] }
Expand Down
23 changes: 22 additions & 1 deletion examples/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/amm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ We use the test-only CLI option `--testing-prng-seed` to make keys deterministic
explanation.

```bash
OWNER_1=7c99bdc355cbbe89d5e0aa512d60fe5c634f42d5445d7e3b58d3206e24babfe3
OWNER_2=537d77c0dfdb9dfedefa8fef04c93013cbf2f4da9a179b1b3aa0fdb6da8244a2
OWNER_1=789dcf5afb0afb9c5c473568bab33c68b83005bf7b964dc2a93e5d4368a9da1f
OWNER_2=38e7f6b6d1887b0ea1511e04a08382577aaf551bb440ee6011966d73d19b8150
CHAIN_1=678e9f66507069d38955b593e93ddf192a23a4087225fd307eadad44e5544ae3
CHAIN_2=a3edc33d8e951a1139333be8a4b56646b5598a8f51216e86592d881808972b07
CHAIN_AMM=aee928d4bf3880353b4a3cd9b6f88e6cc6e5ed050860abae439e7782e9b2dfe8
OWNER_AMM=513bb0b9fdf2d671fa3c44add540f383aada343b34260cff6220d390f2336c4b
OWNER_AMM=de166237331a2966d8cf6778e81a8c007b4084be80dc1e0409d51f216c1deaa1
```

Now we have to publish and create the fungible applications. The flag `--wait-for-outgoing-messages` waits until a quorum of validators has confirmed that all sent cross-chain messages have been delivered.
Expand Down
2 changes: 1 addition & 1 deletion examples/counter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ explanation.

```bash
CHAIN_1=aee928d4bf3880353b4a3cd9b6f88e6cc6e5ed050860abae439e7782e9b2dfe8
OWNER_1=513bb0b9fdf2d671fa3c44add540f383aada343b34260cff6220d390f2336c4b
OWNER_1=de166237331a2966d8cf6778e81a8c007b4084be80dc1e0409d51f216c1deaa1
```

Now, compile the `counter` application WebAssembly binaries, publish and create an application instance.
Expand Down
6 changes: 3 additions & 3 deletions examples/crowd-funding/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ predictable.

```bash
CHAIN_0=aee928d4bf3880353b4a3cd9b6f88e6cc6e5ed050860abae439e7782e9b2dfe8
OWNER_0=513bb0b9fdf2d671fa3c44add540f383aada343b34260cff6220d390f2336c4b
OWNER_0=de166237331a2966d8cf6778e81a8c007b4084be80dc1e0409d51f216c1deaa1
CHAIN_1=582843bc9322ed1928239ce3f6a855f6cd9ea94c8690907f113d6d7a8296a119
OWNER_1=79539f482c1a7fefd5c1fe66572498fd343c0410e29bc83fc59939e6804fdf1b
OWNER_1=849baa540589d95e167d2622018fa341553bf2aff9f328d760443282c6654deb
```

Alternatively, the command below can be used to list the chains created for the test as
Expand All @@ -89,7 +89,7 @@ A table will be shown with the chains registered in the wallet and their meta-da
│ Chain Id ┆ Latest Block │
╞══════════════════════════════════════════════════════════════════╪══════════════════════════════════════════════════════════════════════════════════════╡
│ 582843bc9322ed1928239ce3f6a855f6cd9ea94c8690907f113d6d7a8296a119 ┆ Public Key: 84eddaaafce7fb923c3b2494b3d25e54e910490a726ad9b3a2228d3fb18f9874 │
│ ┆ Owner: 79539f482c1a7fefd5c1fe66572498fd343c0410e29bc83fc59939e6804fdf1b
│ ┆ Owner: 849baa540589d95e167d2622018fa341553bf2aff9f328d760443282c6654deb
│ ┆ Block Hash: - │
│ ┆ Timestamp: 2023-06-28 09:53:51.167301 │
│ ┆ Next Block Height: 0 │
Expand Down
2 changes: 1 addition & 1 deletion examples/fungible/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ would not be predictable without `--testing-prng-seed` above.)

```bash
CHAIN_1=aee928d4bf3880353b4a3cd9b6f88e6cc6e5ed050860abae439e7782e9b2dfe8 # default chain for the wallet
OWNER_1=513bb0b9fdf2d671fa3c44add540f383aada343b34260cff6220d390f2336c4b # owner of chain 1
OWNER_1=de166237331a2966d8cf6778e81a8c007b4084be80dc1e0409d51f216c1deaa1 # owner of chain 1
CHAIN_2=63620ea465af9e9e0e8e4dd8d21593cc3a719feac5f096df8440f90738f4dbd8 # another chain in the wallet
OWNER_2=598d18f67709fe76ed6a36b75a7c9889012d30b896800dfd027ee10e1afd49a3 # owner of chain 2
```
Expand Down
2 changes: 1 addition & 1 deletion examples/gen-nft/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Refer to the [fungible app README](https://github.com/linera-io/linera-protocol/
linera wallet show

CHAIN_1=aee928d4bf3880353b4a3cd9b6f88e6cc6e5ed050860abae439e7782e9b2dfe8 # default chain for the wallet
OWNER_1=513bb0b9fdf2d671fa3c44add540f383aada343b34260cff6220d390f2336c4b # owner of chain 1
OWNER_1=de166237331a2966d8cf6778e81a8c007b4084be80dc1e0409d51f216c1deaa1 # owner of chain 1
CHAIN_2=63620ea465af9e9e0e8e4dd8d21593cc3a719feac5f096df8440f90738f4dbd8 # another chain in the wallet
OWNER_2=598d18f67709fe76ed6a36b75a7c9889012d30b896800dfd027ee10e1afd49a3 # owner of chain 2
```
Expand Down
10 changes: 5 additions & 5 deletions examples/hex-game/tests/hex_game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

use hex_game::{HexAbi, Operation, Timeouts};
use linera_sdk::{
base::{Amount, ChainDescription, KeyPair, TimeDelta},
base::{Amount, ChainDescription, SigningKey, TimeDelta},
test::{ActiveChain, QueryOutcome, TestValidator},
};

#[test_log::test(tokio::test)]
async fn hex_game() {
let key_pair1 = KeyPair::generate();
let key_pair2 = KeyPair::generate();
let key_pair1 = SigningKey::generate();
let key_pair2 = SigningKey::generate();

let (validator, app_id, creation_chain) =
TestValidator::with_current_application::<HexAbi, _, _>((), Timeouts::default()).await;
Expand Down Expand Up @@ -74,8 +74,8 @@ async fn hex_game() {

#[tokio::test]
async fn hex_game_clock() {
let key_pair1 = KeyPair::generate();
let key_pair2 = KeyPair::generate();
let key_pair1 = SigningKey::generate();
let key_pair2 = SigningKey::generate();

let timeouts = Timeouts {
start_time: TimeDelta::from_secs(60),
Expand Down
6 changes: 3 additions & 3 deletions examples/matching-engine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ We use the test-only CLI option `--testing-prng-seed` to make keys deterministic
explanation.

```bash
OWNER_1=513bb0b9fdf2d671fa3c44add540f383aada343b34260cff6220d390f2336c4b
OWNER_2=537d77c0dfdb9dfedefa8fef04c93013cbf2f4da9a179b1b3aa0fdb6da8244a2
OWNER_3=7c99bdc355cbbe89d5e0aa512d60fe5c634f42d5445d7e3b58d3206e24babfe3
OWNER_1=de166237331a2966d8cf6778e81a8c007b4084be80dc1e0409d51f216c1deaa1
OWNER_2=38e7f6b6d1887b0ea1511e04a08382577aaf551bb440ee6011966d73d19b8150
OWNER_3=789dcf5afb0afb9c5c473568bab33c68b83005bf7b964dc2a93e5d4368a9da1f
CHAIN_1=aee928d4bf3880353b4a3cd9b6f88e6cc6e5ed050860abae439e7782e9b2dfe8
CHAIN_2=a3edc33d8e951a1139333be8a4b56646b5598a8f51216e86592d881808972b07
PUB_KEY_1=fcf518d56455283ace2bbc11c71e684eb58af81bc98b96a18129e825ce24ea84
Expand Down
2 changes: 1 addition & 1 deletion examples/native-fungible/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Most of this can also be referred to the [fungible app README](https://github.co
```bash
linera wallet show
CHAIN_1=aee928d4bf3880353b4a3cd9b6f88e6cc6e5ed050860abae439e7782e9b2dfe8 # default chain for the wallet
OWNER_1=513bb0b9fdf2d671fa3c44add540f383aada343b34260cff6220d390f2336c4b # owner of chain 1
OWNER_1=de166237331a2966d8cf6778e81a8c007b4084be80dc1e0409d51f216c1deaa1 # owner of chain 1
CHAIN_2=63620ea465af9e9e0e8e4dd8d21593cc3a719feac5f096df8440f90738f4dbd8 # another chain in the wallet
OWNER_2=598d18f67709fe76ed6a36b75a7c9889012d30b896800dfd027ee10e1afd49a3 # owner of chain 2
```
Expand Down
2 changes: 1 addition & 1 deletion examples/non-fungible/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Refer to the [fungible app README](https://github.com/linera-io/linera-protocol/
linera wallet show

CHAIN_1=aee928d4bf3880353b4a3cd9b6f88e6cc6e5ed050860abae439e7782e9b2dfe8 # default chain for the wallet
OWNER_1=513bb0b9fdf2d671fa3c44add540f383aada343b34260cff6220d390f2336c4b # owner of chain 1
OWNER_1=de166237331a2966d8cf6778e81a8c007b4084be80dc1e0409d51f216c1deaa1 # owner of chain 1
CHAIN_2=63620ea465af9e9e0e8e4dd8d21593cc3a719feac5f096df8440f90738f4dbd8 # another chain in the wallet
OWNER_2=598d18f67709fe76ed6a36b75a7c9889012d30b896800dfd027ee10e1afd49a3 # owner of chain 2
```
Expand Down
4 changes: 2 additions & 2 deletions examples/rfq/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ explanation.
```bash
export CHAIN_0=aee928d4bf3880353b4a3cd9b6f88e6cc6e5ed050860abae439e7782e9b2dfe8
export CHAIN_1=582843bc9322ed1928239ce3f6a855f6cd9ea94c8690907f113d6d7a8296a119
export OWNER_0=513bb0b9fdf2d671fa3c44add540f383aada343b34260cff6220d390f2336c4b
export OWNER_1=79539f482c1a7fefd5c1fe66572498fd343c0410e29bc83fc59939e6804fdf1b
export OWNER_0=de166237331a2966d8cf6778e81a8c007b4084be80dc1e0409d51f216c1deaa1
export OWNER_1=849baa540589d95e167d2622018fa341553bf2aff9f328d760443282c6654deb
```

The `--extra-wallets 1` option creates an additional user chain and wallet - we will use it for the
Expand Down
1 change: 1 addition & 0 deletions linera-base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ linera-witty = { workspace = true, features = ["macros"] }
prometheus = { workspace = true, optional = true }
proptest = { workspace = true, optional = true, features = ["alloc"] }
rand.workspace = true
secp256k1.workspace = true
serde.workspace = true
serde-name.workspace = true
serde_bytes.workspace = true
Expand Down
Loading

0 comments on commit 7ba6ce5

Please sign in to comment.