Is there any built-in function to validate digital signature in Daml?

126 Views Asked by At

I want to look at libraries that can implement crypto functions to validate digital signatures.

3

There are 3 best solutions below

0
On

It would be helpful to understand what you're trying to achieve with signature verification.

In cryptocurrencies, public cryptographic primitives are needed since public keys define the identity, in other words the signatures need to be verifiable publicly. In Daml this is usually not needed, since party defines the identity and most information is inherently private to some group. As such, public verification isn't a common use case.

One way to use cryptographic primitives alongside Daml is to have clients of the Ledger API(s) sign and verify signatures. For example, if I want to authenticate that a specific human is performing an action based on a smart card in their possession, part of the workflow could include:

  1. a party verifier create a random nonce as a challenge which is written to a contract
  2. a party alice use her smart card to sign the nonce and submitting the signature as a choice parameter
  3. party verifier validate the signature in order to progress the workflow
0
On

There's no built-in function to validate signatures in Daml. All signature validation happens through the signatory declaration on templates which should be flexible enough via various patterns to handle signatures validation however you need.

0
On

If you are using DAML, below is the code to accept crypto coin issued, here you can add your conditional verify or check coinAgreement.issuer go here

For e.g. verify he is both issuer and owner

coinIssuerVerify <- queryFilter @coinIssuerVerify issuer
    (\cI -> (cI.issuer == issuer) && (cI.owner == owner))
template CoinIssue
  with
    coinAgreement: CoinIssueAgreement
  where
    signatory coinAgreement.issuer

    controller coinAgreement.owner can
      AcceptCoinProposal
        : ContractId CoinIssueAgreement
        do create coinAgreement