-
Notifications
You must be signed in to change notification settings - Fork 35
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
Replace public_key_registry
from cis3_sponsored_transaction
with corresponding smart contract features
#318
Conversation
d9d1177
to
6954787
Compare
37c6f47
to
965754a
Compare
40a4de0
to
7fd0076
Compare
47d95ba
to
5f39029
Compare
@@ -22,8 +22,8 @@ quickcheck = {version = "1", optional = true } | |||
getrandom = { version = "0.2", features = ["custom"], optional = true } | |||
|
|||
[dependencies.concordium-contracts-common] | |||
path = "../concordium-contracts-common/concordium-contracts-common" | |||
version = "7.0" | |||
path = "../../../LocalTestingLibrary/concordium-smart-contract-tools/concordium-base/concordium-contracts-common/concordium-contracts-common" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am still not sure what the best option for this is. Once we release the libraries we can use the published ones for this PR, but we should also try to think about a long-term solution.
let mut inner_key_map: BTreeMap<KeyIndex, VerifyKey> = BTreeMap::new(); | ||
|
||
inner_key_map.insert( | ||
KeyIndex(0u8), | ||
VerifyKey::Ed25519VerifyKey( | ||
ed25519_dalek::PublicKey::from_bytes(&PUBLIC_KEY) | ||
.expect("Should be able to create public key"), | ||
), | ||
); | ||
|
||
let credential_public_keys = CredentialPublicKeys { | ||
keys: inner_key_map, | ||
threshold: SignatureThreshold::ONE, | ||
}; | ||
|
||
let mut key_map: BTreeMap<CredentialIndex, CredentialPublicKeys> = BTreeMap::new(); | ||
key_map.insert( | ||
CredentialIndex { | ||
index: 0u8, | ||
}, | ||
credential_public_keys, | ||
); | ||
|
||
let keys = AccountAccessStructure { | ||
keys: key_map, | ||
threshold: AccountThreshold::ONE, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let mut inner_key_map: BTreeMap<KeyIndex, VerifyKey> = BTreeMap::new(); | |
inner_key_map.insert( | |
KeyIndex(0u8), | |
VerifyKey::Ed25519VerifyKey( | |
ed25519_dalek::PublicKey::from_bytes(&PUBLIC_KEY) | |
.expect("Should be able to create public key"), | |
), | |
); | |
let credential_public_keys = CredentialPublicKeys { | |
keys: inner_key_map, | |
threshold: SignatureThreshold::ONE, | |
}; | |
let mut key_map: BTreeMap<CredentialIndex, CredentialPublicKeys> = BTreeMap::new(); | |
key_map.insert( | |
CredentialIndex { | |
index: 0u8, | |
}, | |
credential_public_keys, | |
); | |
let keys = AccountAccessStructure { | |
keys: key_map, | |
threshold: AccountThreshold::ONE, | |
}; | |
let rng = &mut rand::thread_rng(); | |
let keypairs = AccountKeys::singleton(rng); | |
let keys: AccountAccessStructure = (&keypairs).into(); |
let mut inner_signature_map = BTreeMap::new(); | ||
inner_signature_map.insert(0u8, concordium_std::Signature::Ed25519(SIGNATURE_UPDATE_OPERATOR)); | ||
|
||
let mut signature_map = BTreeMap::new(); | ||
signature_map.insert(0u8, CredentialSignatures { | ||
sigs: inner_signature_map, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we unify AccountSignature and TransactionSignature this will become
let signature = keypairs.sign(&to_bytes(...))
let mut inner_key_map: BTreeMap<u8, PublicKey> = BTreeMap::new(); | ||
|
||
inner_key_map.insert(0u8, PublicKey::Ed25519(concordium_std::PublicKeyEd25519(PUBLIC_KEY))); | ||
|
||
let credential_public_keys = concordium_std::CredentialPublicKeys { | ||
keys: inner_key_map, | ||
threshold: SignatureThreshold::ONE, | ||
}; | ||
|
||
let mut key_map: BTreeMap<u8, concordium_std::CredentialPublicKeys> = BTreeMap::new(); | ||
key_map.insert(0u8, credential_public_keys); | ||
|
||
let account_public_keys: AccountPublicKeys = AccountPublicKeys { | ||
keys: key_map, | ||
threshold: AccountThreshold::ONE, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let mut inner_key_map: BTreeMap<u8, PublicKey> = BTreeMap::new(); | |
inner_key_map.insert(0u8, PublicKey::Ed25519(concordium_std::PublicKeyEd25519(PUBLIC_KEY))); | |
let credential_public_keys = concordium_std::CredentialPublicKeys { | |
keys: inner_key_map, | |
threshold: SignatureThreshold::ONE, | |
}; | |
let mut key_map: BTreeMap<u8, concordium_std::CredentialPublicKeys> = BTreeMap::new(); | |
key_map.insert(0u8, credential_public_keys); | |
let account_public_keys: AccountPublicKeys = AccountPublicKeys { | |
keys: key_map, | |
threshold: AccountThreshold::ONE, | |
}; | |
let account_public_keys = (&keypairs).into(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first version only supported accounts with one key, and the reason I remember for this was to simplify the endpoints for registering keys. So now that we are removing those endpoints, I think we should support multi-sig accounts here
5f39029
to
cd9883e
Compare
Purpose
addresses #258
After the new protocol update P6, smart contracts can now get the
public_keys
of accounts within the smart contract code. There is also a newcheck_account_signature
function available.The
public_key_registry
is not necessary anymore in the sponsored transaction smart contract and should be replaced.Note: This PR is a draft and has some local dependencies hardcoded to simplify the use of a "local/unreleased" smart contract testing integration library. This needs to be updated/changed before merging.
https://github.com/Concordium/concordium-smart-contract-tools/tree/main/concordium-smart-contract-testing
Changes
public_key_registry
.check_account_signature
to verify the signature in the smart contract.publicKeyOf
function (returned a tuple pair (public key, nonce)) with two separate functionspublicKeyOf
(returns public keys for a vector of accounts) andnonceOf
(returns nonces for a vector of accounts).Signature/PublicKey
types were removed fromconcordium_std
and are now available viaconcordium_contracts_common
.