Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sentinel-lib): Add support to generic event signing #1

Merged
merged 26 commits into from
May 17, 2024
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
6bde57b
fix(sentinel-app): <- rm user op cancellor loop
gskapka May 1, 2024
62fa5b6
feat(sentinel-lib): <- adds events list to config
gskapka May 8, 2024
9284dd5
feat(sentinel-lib): <- adds barebones `SignedEvent` struct
gskapka May 8, 2024
8b4d4f5
feat(sentinel-lib): <- adds required fields to signed event struct
gskapka May 8, 2024
38fe038
feat(sentinel-lib): <- flesh out signed event parser more
gskapka May 8, 2024
ef6108c
feat(sentinel-lib): <- adds method to network id from network config
gskapka May 9, 2024
2ab62c2
feat(sentinel-lib): <- adds `empty` method to `SignedEvents`
gskapka May 9, 2024
1934d77
feat(sentinel-lib): <- update processor to return `SignedEvents` inst…
gskapka May 9, 2024
56ff894
fix(sentinel-lib): <- rm unused batching fxn
gskapka May 9, 2024
3e3ff5e
feat(sentinel-app): <- add `todo!` to that where `ProcessorOutput` sh…
gskapka May 9, 2024
25a5629
feat(sentinel-lib): <- adds eth receipt merkle proving fxn to that
gskapka May 9, 2024
5f6d9c1
feat(sentinel-lib): <- `wire up process_single` in processor
gskapka May 9, 2024
34a5e24
feat(sentinel-lib): <- adds in method to create `SignedEvent`
gskapka May 9, 2024
416e1e2
feat(sentinel-lib): <- make fields public in `ConfiguredEvent`
gskapka May 9, 2024
df537f5
feat(sentinel-lib): <- move merkle stuff to merkle mod
gskapka May 10, 2024
444ed4f
feat(sentinel-lib): <- use full submat in processor instead of just r…
gskapka May 10, 2024
365dcd3
chore(sentinel-lib): <- fix clippy lints
gskapka May 10, 2024
ee4fe4c
feat(sentinel-lib): <- adds `SignedEvents` parsing logic from submat
gskapka May 10, 2024
19d2edd
feat(sentinel-lib): implement encode for SignedEvent
ubordignon May 14, 2024
018de8c
feat(sentinel-lib): test signed events TryFrom implementation
ubordignon May 14, 2024
5b25d61
feat(sentinel-lib): add merkle root calculation test
ubordignon May 17, 2024
005a66d
fix(sentinel-lib): use transaction index to generate merkle proof
ubordignon May 17, 2024
53207e1
feat(sentinel-lib): add merkle proof test
ubordignon May 17, 2024
2363502
fix: pass through `NetworkConfig` instead of `NetworkId` as expected …
gitmp01 May 14, 2024
0278319
fix(android): initialize keystore upon startup
gitmp01 May 15, 2024
e1d7b70
ref(sentinel-lib): comply with signed event spec
ubordignon May 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions common/sentinel/src/signed_events/signed_event.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use common::types::Bytes;
use common_chain_ids::EthChainId;
use common_eth::{EthLog, EthPrivateKey, EthSigningCapabilities};
use common_metadata::MetadataChainId;
use common_metadata::{MetadataChainId, MetadataProtocolId};
use derive_getters::Getters;
use ethereum_types::H256 as EthHash;
use serde::{Deserialize, Serialize};
Expand Down Expand Up @@ -36,13 +38,24 @@ impl SignedEvent {
metadata_chain_id,
version: SignedEventVersion::current(),
};
let hash = signed_event.encode()?;
let sig = pk.sha256_hash_and_sign_msg(hash.0.as_slice())?;
let signed_event_encoded = signed_event.encode();
let sig = pk.sha256_hash_and_sign_msg(signed_event_encoded.as_slice())?;
signed_event.signature = Some(sig.to_string());
Ok(signed_event)
}

fn encode(&self) -> Result<EthHash, SignedEventError> {
todo!("encode via gitmp01's spec");
fn encode(&self) -> Bytes {
// FIXME sha256(protocol, protocol_chain_id, blockhash, unique_event_identifier_such_as_merklepathonevm)
// Currently, random 32 bytes
let event_id = &[0xab, 0xcd, 0xee, 0xff];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, as discussed.

[
self.version.as_bytes(),
&[MetadataProtocolId::Ethereum.to_byte()],
EthChainId::Mainnet.to_bytes().as_ref().unwrap(),
event_id,
&self.log.data.len().to_le_bytes(),
self.log.data.as_ref(),
]
.concat()
}
}