https://github.com/cardano-foundation/cip30-data-signature-parser
Java implementation of CIP-30 DataSignature parsing and validation
https://github.com/cardano-foundation/cip30-data-signature-parser
Last synced: 11 days ago
JSON representation
Java implementation of CIP-30 DataSignature parsing and validation
- Host: GitHub
- URL: https://github.com/cardano-foundation/cip30-data-signature-parser
- Owner: cardano-foundation
- License: mit
- Created: 2022-10-18T20:13:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-09T10:59:07.000Z (over 1 year ago)
- Last Synced: 2024-08-03T18:14:55.296Z (10 months ago)
- Language: Java
- Homepage:
- Size: 239 KB
- Stars: 6
- Watchers: 10
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# Java CIP-30 Data Signature Parser and Validator
[](https://github.com/cardano-foundation/cip30-data-signature-parser/actions/workflows/maven-build.yml)
[](https://github.com/cardano-foundation/cip30-data-signature-parser/actions/workflows/codeql.yml)

[](https://github.com/cardano-foundation/cip30-data-signature-parser/blob/master/LICENSE)

[](https://javadoc.io/doc/org.cardanofoundation/cip30-data-signature-parser)
## Introduction
Implementation in Java of CIP-30 Data Signature Parser and Validator (https://github.com/cardano-foundation/CIPs/tree/master/CIP-0030).
This library is useful in situation where your project is JVM based and you need to parse / validate CIP-30 data signature and extract information encoded in it.## Features
In particular this library allows you to get / validate:
- validate CIP-30 data signed envelop (DataSignature) using either embedded public key or explicitly supplied key (CIP-30 data signature should contain public key)
- get message from the data signature envelope
- get stored Cardano address
- get ED 25519 public key and ED 25519 signature encoded in it
- get COSE payload (COSE wrapped message directly signed by the algorithm)
- library makes it easy to extract (ED 25519 public key and ED 25519 signature as well as COSE payload)## Additional Docs
- [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md)
- [SECURITY.md](SECURITY.md)
- [CONTRIBUTING.md](CONTRIBUTING.md)
- [CHANGELOG.md](CHANGELOG.md)
- [GLOSSARY.md](GLOSSARY.md)## Requirements
Java 17 LTS or greater## Building
```
git clone https://github.com/cardano-foundation/cip30-data-signature-parser
cd cip30-data-signature-parser
mvn clean package
```## Dependency
```xmlorg.cardanofoundation
cip30-data-signature-parser
0.0.11```
## Example Usage
```java
var sig = "84582aa201276761646472657373581de1b83abf370a14870fdfd6ccb35f8b3e62a68e465ed1e096c5a6f5b9d6a166686173686564f4565468697320697320612074657374206d657373616765584042e2bfc4e1929769a0501b884f66794ae3485860f42c01b70fac37f75e40af074c6b2a61b04c6cf8a493c0dced1455b4f1129dbf653ad9801c52ce49ff6d5a0e";
var key = "a40101032720062158202f1867873147cf53c442435723c17e83beeb8e2153851cd73ccfb1b5e68994a4";var verifier = new CIP30Verifier(sig, key);
var verificationResult = verifier.verify();
System.out.println("is valid?: " + verificationResult.isValid());
System.out.println("Optional address(bech32): " + verificationResult.getAddress(AddressFormat.TEXT).orElseThrow());
System.out.println("Message: " + result.getMessage(TEXT));
```
produces
```
is valid?: true
Optional address(bech32): stake1uxur40ehpg2gwr7l6mxtxhut8e32drjxtmg7p9k95m6mn4s0tdy6k
Message: This is a test message
```# Caveats / Notes
- parser is strict, meaning it won't be possible to extract / get various fields if a CIP-30 signature is invalid, alternatively one can develop one with lenient parsing.