Skip to content

Commit

Permalink
Credential registry (#241)
Browse files Browse the repository at this point in the history
* Add initial version of the registry

* Add todos; rename get_keys to get_issuer_keys

* Add basic owner authorization

* Factor out sender_is_owner

* Add revocation authorization for holder; improve arbitrary for serialization schema

* Refactoring: use ensure! instead of conditionals

* Change key index to u8; factor out signature based authorization; add authorization based on revocation keys

* Add an entrypoint to view revocation key and nonce

* Add events

* Renamed get to view

* Batch add/remove of public keys

* Use MetadataUrl from CIS2

* Restructure CredentialData; add more tests: get_status, add/view keys; fix NotAcivated behaviour of get_status

* Docs for tests

* Documentation

* Test entrypoints; change commitments to Vec

* Add credential registry to CI

* Fix Uuidv4 parameter

* Fix message in test

* Remove view state entrypoint

* Remove files added by accident

* Apply suggestions from code review

Co-authored-by: Emil Holm Gjørup <[email protected]>

* Address some review comments

* Suggestions

* Fix view_revocation_key return type; apply suggestions

* Suggestions

* Fix docs; add to readme

* Remove serialization schema; add separate CredentialEntryResponse for credential data queries; remove redundant Arbitrary implementations

* Derive PartialEq, Eq for MetadataUrl

* Fix clippy warning after @DOBEN suggestions

* Split revoke entrypoint

* Remove updateCredential; use StateBox for CredentialData

* Comments for revocation parameters

* Restructure input/response data structures; restructure credential data and change the use of StateBox

* fix comments

* Use issuer instead of contract's owner

* Clarify a note

* Clarify a note more

* Fix signed message: add reason and revocation_key_index (depending on which signature is verified)

* Add credential type and a schema registry; un-revoking (restoring) by issuers; remove view prefix in entrypoint names

* Add schema updates; fix documentation

* Update docs

* Use CredentialID instead of Uuidv4; keep it a u128 integer

* Remove holder_restorable

* Apply suggestions from code review

Co-authored-by: Doris Benda <[email protected]>

* Address feedback; change field order in CredentialInfo and CredentialQueryResponse

* Rename RevokeReason to Reason, because it's used both in revoking and restoring

* Add concordium-quickcheck feature to concordium-std dependency

* Remove getrandom

* Rename secret key to private key

* Log restoration event

* Add credential restoration tests; log tagged events everywhere

* Fix clippy warnings

* Fix formatting

* Add serialization helpers

* Add entry_point to SigningData

* Make newtype for CredentialType

* Fix docs

* Add redection case in registerCredential; typos

* Use u16 indices for public keys

* Make valid_from non-optional

* Misc changes (#276)

* Changes and simplifications.

* Address review comments.

* Fix removal of revocation keys.

* Remove issuer keys.

* Add functions for updating credential metadata, and emitting relevant events.

* Remove unused Update event, fix serialization.

* Fix signature checking.

* Remove the use of credential IDs (uuids).

* Update examples/credential-registry/src/lib.rs

* Add comments; fix holder revocation test

---------

Co-authored-by: Danil Annenkov <[email protected]>

* Bump concordium std to 6.2, fix credential id type in schemas

* Fix docs

* Update documentation; fix error for revocation key lookup

* Change tag for Restore; add comments about event tagging

* Add revocation key event

* Remove cis2 dependency; address comments

* Add schema_ref to credential registration test

---------

Co-authored-by: Emil Holm Gjørup <[email protected]>
Co-authored-by: Doris Benda <[email protected]>
Co-authored-by: Aleš Bizjak <[email protected]>
  • Loading branch information
4 people authored May 30, 2023
1 parent 067fcfb commit 7892408
Show file tree
Hide file tree
Showing 5 changed files with 2,017 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
- examples/cis2-nft/Cargo.toml
- examples/cis3-nft-sponsored-txs/Cargo.toml
- examples/cis2-wccd/Cargo.toml
- examples/credential-registry/Cargo.toml
- examples/fib/Cargo.toml
- examples/icecream/Cargo.toml
- examples/memo/Cargo.toml
Expand Down Expand Up @@ -449,6 +450,7 @@ jobs:
- examples/nametoken/Cargo.toml
- examples/signature-verifier/Cargo.toml
- examples/cis3-nft-sponsored-txs/Cargo.toml
- examples/credential-registry/Cargo.toml

steps:
- name: Checkout sources
Expand Down Expand Up @@ -487,6 +489,7 @@ jobs:
- examples/cis2-nft/Cargo.toml
- examples/cis3-nft-sponsored-txs/Cargo.toml
- examples/cis2-wccd/Cargo.toml
- examples/credential-registry/Cargo.toml
- examples/fib/Cargo.toml
- examples/icecream/Cargo.toml
- examples/memo/Cargo.toml
Expand Down Expand Up @@ -615,6 +618,7 @@ jobs:
- examples/cis2-nft/Cargo.toml
- examples/cis3-nft-sponsored-txs/Cargo.toml
- examples/cis2-wccd/Cargo.toml
- examples/credential-registry/Cargo.toml
- examples/fib/Cargo.toml
- examples/icecream/Cargo.toml
- examples/memo/Cargo.toml
Expand Down
15 changes: 15 additions & 0 deletions concordium-std/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,21 @@ impl FromStr for PublicKeyEd25519 {
}
}

#[cfg(feature = "concordium-quickcheck")]
/// Arbitrary public keys.
/// Note that this is a simple generator that might produce an array of bytes
/// that is not a valid public key.
impl quickcheck::Arbitrary for PublicKeyEd25519 {
fn arbitrary(g: &mut quickcheck::Gen) -> Self {
let lower: u128 = quickcheck::Arbitrary::arbitrary(g);
let upper: u128 = quickcheck::Arbitrary::arbitrary(g);
let mut out = [0u8; 32];
out[..16].copy_from_slice(&lower.to_le_bytes());
out[16..].copy_from_slice(&upper.to_le_bytes());
PublicKeyEd25519(out)
}
}

/// Public key for ECDSA over Secp256k1. Must be 33 bytes long.
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Eq, Ord)]
#[repr(transparent)]
Expand Down
2 changes: 2 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ The list of contracts is as follows
- [voting](./voting) An example of how to conduct an election using a smart contract.
- [transfer-policy-check](./transfer-policy-check) A contract that showcases how to use policies.
- [eSealing](./eSealing) A contract implementing an eSealing service.
- [credential-registry](./credential-registry/) A contract for storing and managing public data of verifiable credentials.
- [sponsoredTransactions](./cis3-nft-sponsored-txs) A contract implementing the sponsored transaction mechanism (CIS3 standard).
- [smartContractUpgrade](./smart-contract-upgrade) An example of how to upgrade a smart contract. The state is migrated during the upgrade.
- [credentialRegistryStorageContract](./credential-registry-storage-contract) The contract is used for storing credentials for the Web3Id infrastructure.


26 changes: 26 additions & 0 deletions examples/credential-registry/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[package]
name = "credential_registry"
version = "0.1.0"
edition = "2021"
license = "MPL-2.0"
authors = [ "Concordium <[email protected]>" ]
description = "An example credential registry smart contract"

[features]
default = ["std", "crypto-primitives", "wee_alloc"]
std = ["concordium-std/std"]
wee_alloc = ["concordium-std/wee_alloc"]
crypto-primitives = ["concordium-std/crypto-primitives"]

[dependencies]
concordium-std = {path = "../../concordium-std", version="6.2", features = ["concordium-quickcheck"], default-features = false}
quickcheck = {version = "1"}

[lib]
crate-type=["cdylib", "rlib"]

[profile.release]
opt-level = "s"
codegen-units = 1
Loading

0 comments on commit 7892408

Please sign in to comment.