Skip to content

Fix extraction of Cardano Addresses from a cardano address URI string #100

@stevenj

Description

@stevenj

Summary

Addresss are not being extracted as full addresses by the cip509 library, fix that.

Description

This function:

pub fn extract_cip19_hash(uri: &str, prefix: Option<&str>) -> Option<Vec<u8>> {

Is extracting a hash from a string encoded cardano address, that can be found inside both C509 and X509 certificates.
It is incorrectly over-processing the data, making the public function not very usable, and requiring it to be rewritten for multiple different use cases.

The URL format is defined here: https://github.com/cardano-foundation/CIPs/pull/888/files

It needs to be fixed to return an enum type containing this type:

The data this function is returning (the hash) is available from this type, but this allows the function to also return anything known about the address, not just its hash. This is critical behaviour for the RBAC implementation in cat-gateway.

This function needs to be publicly accessible from the library.

All code which uses this function will need to be adjusted to work with its new result.

One way to do that could be:

  1. Create a new public function: parse_cip00134_uri(uri: &str) -> Result<pallas_addresses::Address> { ... }
  2. Modify extract_cip19_hash to use this function (and make it private to the crate as it should not be used by any consumer of the crate).

NOTE: A second implementation of this function currently exists within catalyst-libs/main/rust/cardano-chain-follower ignore this, as it will be removed at some future point when that library is refactored to use this new rbac-registration library.

Subtask List

Metadata

Metadata

Labels

Type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions