Skip to content

Commit 58a8cc2

Browse files
committed
revert
1 parent ec48143 commit 58a8cc2

File tree

2 files changed

+45
-3
lines changed
  • rust/rbac-registration/src

2 files changed

+45
-3
lines changed

rust/rbac-registration/src/cardano/cip509/cip509.rs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use catalyst_types::{
2222
uuid::UuidV4,
2323
};
2424
use cbork_utils::decode_helper::{decode_bytes, decode_helper, decode_map_len};
25+
use ed25519_dalek::VerifyingKey;
2526
use minicbor::{
2627
decode::{self},
2728
Decode, Decoder,
@@ -32,6 +33,7 @@ use uuid::Uuid;
3233

3334
use crate::cardano::cip509::{
3435
decode_context::DecodeContext,
36+
extract_key,
3537
rbac::Cip509RbacMetadata,
3638
types::{PaymentHistory, TxInputHash, ValidationSignature},
3739
utils::Cip0134UriSet,
@@ -40,7 +42,7 @@ use crate::cardano::cip509::{
4042
validate_txn_inputs_hash,
4143
},
4244
x509_chunks::X509Chunks,
43-
Payment, PointTxnIdx, RoleData,
45+
C509Cert, LocalRefInt, Payment, PointTxnIdx, RoleData, SimplePublicKeyType, X509DerCert,
4446
};
4547

4648
/// A x509 metadata envelope.
@@ -227,6 +229,46 @@ impl Cip509 {
227229
self.metadata.as_ref().and_then(|m| m.role_data.get(&role))
228230
}
229231

232+
/// Returns signing public key for a role.
233+
#[must_use]
234+
pub fn signing_pk_for_role(
235+
&self,
236+
role: RoleId,
237+
) -> Option<VerifyingKey> {
238+
self.metadata.as_ref().and_then(|m| {
239+
let key_ref = m.role_data.get(&role).and_then(|d| d.signing_key())?;
240+
match key_ref.local_ref {
241+
LocalRefInt::X509Certs => {
242+
m.x509_certs.get(key_ref.key_offset).and_then(|c| {
243+
if let X509DerCert::X509Cert(c) = c {
244+
extract_key::x509_key(&c).ok()
245+
} else {
246+
None
247+
}
248+
})
249+
},
250+
LocalRefInt::C509Certs => {
251+
m.c509_certs.get(key_ref.key_offset).and_then(|c| {
252+
if let C509Cert::C509Certificate(c) = c {
253+
extract_key::c509_key(&c).ok()
254+
} else {
255+
None
256+
}
257+
})
258+
},
259+
LocalRefInt::PubKeys => {
260+
m.pub_keys.get(key_ref.key_offset).and_then(|c| {
261+
if let SimplePublicKeyType::Ed25519(c) = c {
262+
Some(c.clone())
263+
} else {
264+
None
265+
}
266+
})
267+
},
268+
}
269+
})
270+
}
271+
230272
/// Returns a purpose of this registration.
231273
#[must_use]
232274
pub fn purpose(&self) -> Option<UuidV4> {

rust/rbac-registration/src/registration/cardano/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ impl RegistrationChain {
7979
// Checks that a new registration doesn't contain a signing key that was used by any
8080
// other chain. Returns a list of public keys in the registration.
8181
for role in cip509.all_roles() {
82-
if let Some((key, _)) = new_chain.get_latest_signing_pk_for_role(role) {
82+
if let Some(key) = cip509.signing_pk_for_role(role) {
8383
if let Some(previous) = provider.catalyst_id_from_public_key(&key).await? {
8484
if &previous != cat_id {
8585
cip509.report().functional_validation(
@@ -146,7 +146,7 @@ impl RegistrationChain {
146146
{
147147
let cat_id = self.catalyst_id();
148148
for role in cip509.all_roles() {
149-
if let Some((key, _)) = new_chain.get_latest_signing_pk_for_role(role) {
149+
if let Some(key) = cip509.signing_pk_for_role(role) {
150150
if let Some(previous) = provider.catalyst_id_from_public_key(&key).await? {
151151
if &previous != cat_id {
152152
cip509.report().functional_validation(

0 commit comments

Comments
 (0)