lib/oydid/vc.rb in oydid-0.5.4 vs lib/oydid/vc.rb in oydid-0.5.5

- old
+ new

@@ -50,11 +50,10 @@ if access_token.nil? msg = "invalid repository authentication (access_token)" return [nil, msg] exit end - retVal = HTTParty.get(vc_url, headers: {'Authorization' => 'Bearer ' + access_token}) if retVal.code != 200 if retVal.code == 401 msg = "unauthorized (valid Bearer token required)" @@ -109,11 +108,11 @@ if content["proof"].nil? proof = {} proof["type"] = "Ed25519Signature2020" proof["verificationMethod"] = options[:issuer].to_s proof["proofPurpose"] = "assertionMethod" - proof["proofValue"] = sign(vercred["credentialSubject"].to_json_c14n, options[:issuer_privateKey], []).first + proof["proofValue"] = sign(vercred["credentialSubject"].transform_keys(&:to_s).to_json_c14n, options[:issuer_privateKey], []).first vercred["proof"] = proof else vercred["proof"] = content["proof"] end if vercred["proof"].to_s == "" || vercred["proof"].to_s == "{}" || vercred["proof"].to_s == "[]" @@ -124,9 +123,12 @@ vercred["identifier"] = hash(vercred.to_json) return [vercred, ""] end def self.create_vc_proof(content, options) + if content["id"].nil? + content["id"] = options[:holder] + end proof = {} proof["type"] = "Ed25519Signature2020" proof["verificationMethod"] = options[:issuer].to_s proof["proofPurpose"] = "assertionMethod" proof["proofValue"] = sign(content.to_json_c14n, options[:issuer_privateKey], []).first