public JToken CreateProof(CreateProofOptions options, JsonLdProcessorOptions processorOptions) { if (!(options.VerificationMethod is Bls12381VerificationKey2020 verificationMethod)) { throw new Exception( $"Invalid verification method. " + $"Expected '{nameof(Bls12381VerificationKey2020)}'. " + $"Found '{options.VerificationMethod?.GetType().Name}'."); } // Prepare proof var compactedProof = JsonLdProcessor.Compact( input: new BbsBlsSignature2020 { Context = Constants.SECURITY_CONTEXT_V2_URL, TypeName = "https://w3c-ccg.github.io/ldp-bbs2020/context/v1#BbsBlsSignature2020" }, context: Constants.SECURITY_CONTEXT_V2_URL, options: processorOptions); var proof = new BbsBlsSignature2020(compactedProof) { Context = Constants.SECURITY_CONTEXT_V2_URL, VerificationMethod = options.VerificationMethod switch { VerificationMethodReference reference => (string)reference, VerificationMethod method => method.Id, _ => throw new Exception("Unknown VerificationMethod type") },
public void SerializeDeserializeVerificationMethodReference() { var method = new VerificationMethodReference("did:1234"); var json = JsonConvert.SerializeObject(method); Assert.NotNull(json); var method1 = JsonConvert.DeserializeObject <VerificationMethodReference>(json); Assert.NotNull(method1); Assert.IsType <VerificationMethodReference>(method1); }