Commit a3454588 authored by Sietse Ringers's avatar Sietse Ringers
Browse files

Rename irma.IrmaSignedMessage -> irma.SignedMessage

parent fa9ae993
......@@ -10,9 +10,9 @@ import (
"github.com/mhe/gabi"
)
// IrmaSignedMessage is a message signed with an attribute-based signature
// SignedMessage is a message signed with an attribute-based signature
// The 'realnonce' will be calculated as: SigRequest.GetNonce() = ASN1(nonce, SHA256(message), timestampSignature)
type IrmaSignedMessage struct {
type SignedMessage struct {
Signature gabi.ProofList `json:"signature"`
Nonce *big.Int `json:"nonce"`
Context *big.Int `json:"context"`
......@@ -20,11 +20,11 @@ type IrmaSignedMessage struct {
Timestamp *atum.Timestamp `json:"timestamp"`
}
func (im *IrmaSignedMessage) GetNonce() *big.Int {
func (im *SignedMessage) GetNonce() *big.Int {
return ASN1ConvertSignatureNonce(im.Message, im.Nonce, im.Timestamp)
}
func (im *IrmaSignedMessage) MatchesNonceAndContext(request *SignatureRequest) bool {
func (im *SignedMessage) MatchesNonceAndContext(request *SignatureRequest) bool {
return im.Nonce.Cmp(request.Nonce) == 0 &&
im.Context.Cmp(request.Context) == 0 &&
im.GetNonce().Cmp(request.GetNonce()) == 0
......
......@@ -59,11 +59,11 @@ func (entry *LogEntry) GetIssuedCredentials(conf *irma.Configuration) (list irma
}
// GetSignedMessage gets the signed for a log entry
func (entry *LogEntry) GetSignedMessage() (abs *irma.IrmaSignedMessage, err error) {
func (entry *LogEntry) GetSignedMessage() (abs *irma.SignedMessage, err error) {
if entry.Type != irma.ActionSigning {
return nil, nil
}
return &irma.IrmaSignedMessage{
return &irma.SignedMessage{
Signature: entry.ProofList,
Nonce: entry.SessionInfo.Nonce,
Context: entry.SessionInfo.Context,
......
......@@ -292,7 +292,7 @@ func (sh *ManualSessionHandler) Success(irmaAction irma.Action, result string) {
case irma.ActionSigning:
// Make proof corrupt if we want to test invalid proofs
resultBytes := corruptAndConvertProofString(result)
irmaSignedMessage := &irma.IrmaSignedMessage{}
irmaSignedMessage := &irma.SignedMessage{}
if err := json.Unmarshal(resultBytes, irmaSignedMessage); err != nil {
sh.errorChannel <- &irma.SessionError{
......
......@@ -276,7 +276,7 @@ func TestVerifyValidSig(t *testing.T) {
conf := parseConfiguration(t)
irmaSignedMessageJson := "{\"signature\":[{\"c\":75240648584943108131774861418318016950300520060239897966364931555348119154196,\"A\":11233355237638071473355040022601544318931000499058445952330165003155291452882014950229516980087013355670100886267043109889290196460736758722039876324777132864035863434782644494004016849862082847856434105252669649855602233471390863557544150375601234558196514354266223994618716648803629152866318840314101303053,\"e_response\":70443137280413345388921308658326573478731402976627353520789046075581088830468573907219985143735120271295606500225192886734004566649741300,\"v_response\":748547606963016897781947765348570036269181744245969380678378950063447942583654801250902509594049880144606664155188413917858341097638009280073657058659129276453063845565880273889465070847993483844689057977028173394452669902369437344839036235498559251356581938192107900921870473799941106736017886005831516457330023495088373551591149589202496455594271982293348956823683659852274256453778465505025023577967456370086028145603744587324314475916518584158230288021313776814608153663145234741600118368482896288256771513649394113424970805702242999138114099754431573768005053249476064297389050847313658255952687915513714299,\"a_responses\":{\"0\":4081186988971645773885141302777967291858930640684160885316109083415045388256707780194730929186392387906061383128340576948202521359180637178569455985666827436285079935133224351439,\"2\":2002101875939486065896615754953027178193966422837050583457482787068404012970870896083719080233500166329391569749284832041605767056271290452037190009069979873823861447698576212956,\"3\":9024622614267518591475352106643486923661297308724100043388816444935669356409217421617445580684629339630281696726734306159937045856348975488404957001973413528359503266658980267958,\"5\":14532137354231347732013224301661302047284478108130413918974378286885777087212963236903262642952033662174908068223261418379845579509518210263448355072319547079781612856155479908000},\"a_disclosed\":{\"1\":49043497911096929607726931703203423024551950578089278988,\"4\":3421494}}],\"nonce\":42,\"context\":1337,\"message\":\"I owe you everything\",\"timestamp\":{\"Time\":1527196489,\"ServerUrl\":\"https://metrics.privacybydesign.foundation/atum\",\"Sig\":{\"Alg\":\"ed25519\",\"Data\":\"ZV1qkvDrFK14QrUSC66xTNr9HitCOV4vwfGX0bh3iwY7qyHCi9rIOE97KY8CZifU5oLgVhFWy5E+ALR+gEpACw==\",\"PublicKey\":\"e/nMAJF7nwrvNZRpuJljNpRx+CsT7caaXyn9OX683R8=\"}}}"
irmaSignedMessage := &IrmaSignedMessage{}
irmaSignedMessage := &SignedMessage{}
json.Unmarshal([]byte(irmaSignedMessageJson), irmaSignedMessage)
request := "{\"nonce\": 42, \"context\": 1337, \"message\":\"I owe you everything\",\"content\":[{\"label\":\"Student number (RU)\",\"attributes\":[\"irma-demo.RU.studentCard.studentID\"]}]}"
......@@ -332,7 +332,7 @@ func TestVerifyInValidSig(t *testing.T) {
// Same json as valid case, but starts with c: 74.. instead of c: 84..
irmaSignedMessageJson := "{\"signature\":[{\"c\":74387860940227163820403495286748244564707922600034683359608691396081567025602,\"A\":88281712394778800408977859704145725624282144718487192171772162550525428429519190981888278801087212465321690290335409063053117882098498400332781065742081358484833309192327120556339332157874905818122935827879129997343067882402015244634759393479031207772945330229833048906663580440236616733112577470729616366786,\"e_response\":158765301676865980664519775970491722252026400039481431972586202039855979595012153817023420279082580759592345985626616023615379719752399328,\"v_response\":6611746513363446317846147623316898858155094502709878009639760817201381076603429289631603604529060691249377615651154531801036452874566979268891286567129727685535821475399052346372076099618720496054457827506328803409424296248607363948476756029304344829069350093632120223961428827899945063479494984026332706037701056800933468297084225080081776744374335801370875205735636759162890211232669349095889736548891226015515520674239004969135762927189899345062330063667418982393995289342139999902051131072263853724059860710122540669055502508808347469655730875919155588858804817423089007580489779129833698002045070596906945040,\"a_responses\":{\"0\":4434835936588491146877061202237807779146602258202436880339162159399867035387373999563459639269288401746730567517727346492632152446746295360674508158204107496002345160420756725205,\"2\":9977462643736893130880681297952480237124511902476432783965737452034254055110952583256642665857196544092176573351041403473080012083097371376185951351204344524454609167069034294004,\"3\":1904659714829479350823098920128825893793063661618141776764549847325998719856920007188109803030455877752450027088898741652270026015791752527030236440389575193675041497254880209617,\"5\":3936452247676614466878886279006122732122146262864401884641740995040119769042022356436514614808831282997701569758564908168629905499336984204831548844404122251651655734975885548663},\"a_disclosed\":{\"1\":49043497911096929607726931703203423024551950578089278988,\"4\":3421494}}],\"nonce\":42,\"context\":1337,\"message\":\"I owe you everything\"}"
irmaSignedMessage := &IrmaSignedMessage{}
irmaSignedMessage := &SignedMessage{}
json.Unmarshal([]byte(irmaSignedMessageJson), irmaSignedMessage)
request := "{\"nonce\": 42, \"context\": 1337, \"message\":\"I owe you everything\",\"content\":[{\"label\":\"Student number (RU)\",\"attributes\":[\"irma-demo.RU.studentCard.studentID\"]}]}"
......@@ -353,7 +353,7 @@ func TestVerifyInValidNonce(t *testing.T) {
// Same json as valid case, has invalid nonce
irmaSignedMessageJson := "{\"signature\":[{\"c\":84387860940227163820403495286748244564707922600034683359608691396081567025602,\"A\":88281712394778800408977859704145725624282144718487192171772162550525428429519190981888278801087212465321690290335409063053117882098498400332781065742081358484833309192327120556339332157874905818122935827879129997343067882402015244634759393479031207772945330229833048906663580440236616733112577470729616366786,\"e_response\":158765301676865980664519775970491722252026400039481431972586202039855979595012153817023420279082580759592345985626616023615379719752399328,\"v_response\":6611746513363446317846147623316898858155094502709878009639760817201381076603429289631603604529060691249377615651154531801036452874566979268891286567129727685535821475399052346372076099618720496054457827506328803409424296248607363948476756029304344829069350093632120223961428827899945063479494984026332706037701056800933468297084225080081776744374335801370875205735636759162890211232669349095889736548891226015515520674239004969135762927189899345062330063667418982393995289342139999902051131072263853724059860710122540669055502508808347469655730875919155588858804817423089007580489779129833698002045070596906945040,\"a_responses\":{\"0\":4434835936588491146877061202237807779146602258202436880339162159399867035387373999563459639269288401746730567517727346492632152446746295360674508158204107496002345160420756725205,\"2\":9977462643736893130880681297952480237124511902476432783965737452034254055110952583256642665857196544092176573351041403473080012083097371376185951351204344524454609167069034294004,\"3\":1904659714829479350823098920128825893793063661618141776764549847325998719856920007188109803030455877752450027088898741652270026015791752527030236440389575193675041497254880209617,\"5\":3936452247676614466878886279006122732122146262864401884641740995040119769042022356436514614808831282997701569758564908168629905499336984204831548844404122251651655734975885548663},\"a_disclosed\":{\"1\":49043497911096929607726931703203423024551950578089278988,\"4\":3421494}}],\"nonce\":4242,\"context\":1337,\"message\":\"I owe you everything\"}"
irmaSignedMessage := &IrmaSignedMessage{}
irmaSignedMessage := &SignedMessage{}
json.Unmarshal([]byte(irmaSignedMessageJson), irmaSignedMessage)
// Original request also has the same invalid nonce (otherwise we would get unmatched_request)
......
......@@ -357,14 +357,14 @@ func (sr *SignatureRequest) UnmarshalJSON(b []byte) error {
return err
}
func (sr *SignatureRequest) SignatureFromMessage(message interface{}) (*IrmaSignedMessage, error) {
func (sr *SignatureRequest) SignatureFromMessage(message interface{}) (*SignedMessage, error) {
signature, ok := message.(gabi.ProofList)
if !ok {
return nil, errors.Errorf("Type assertion failed")
}
return &IrmaSignedMessage{
return &SignedMessage{
Signature: signature,
Nonce: sr.Nonce,
Context: sr.Context,
......
......@@ -48,9 +48,9 @@ func TimestampRequest(message string, sigs []*big.Int, disclosed [][]*big.Int) (
const TimestampServerURL = "https://metrics.privacybydesign.foundation/atum"
// Given an IrmaSignedMessage, verify the timestamp over the signed message, disclosed attributes,
// Given an SignedMessage, verify the timestamp over the signed message, disclosed attributes,
// and rerandomized CL-signatures.
func VerifyTimestamp(irmaSignature *IrmaSignedMessage, message string, conf *Configuration) error {
func VerifyTimestamp(irmaSignature *SignedMessage, message string, conf *Configuration) error {
if irmaSignature.Timestamp.ServerUrl != TimestampServerURL {
return errors.New("Untrusted timestamp server")
}
......
......@@ -237,7 +237,7 @@ func addExtraAttributes(disclosed DisclosedCredentialList, proofResult *ProofRes
}
// Check an gabi prooflist against a signature proofrequest
func checkProofWithRequest(configuration *Configuration, irmaSignature *IrmaSignedMessage, sigRequest *SignatureRequest) *SignatureProofResult {
func checkProofWithRequest(configuration *Configuration, irmaSignature *SignedMessage, sigRequest *SignatureRequest) *SignatureProofResult {
disclosed, err := ExtractDisclosedCredentials(configuration, irmaSignature.Signature)
if err != nil {
......@@ -292,7 +292,7 @@ func verify(configuration *Configuration, proofList gabi.ProofList, context *big
}
// Verify a signature proof and check if the attributes match the attributes in the original request
func VerifySig(configuration *Configuration, irmaSignature *IrmaSignedMessage, sigRequest *SignatureRequest) *SignatureProofResult {
func VerifySig(configuration *Configuration, irmaSignature *SignedMessage, sigRequest *SignatureRequest) *SignatureProofResult {
// First check if this signature matches the request
sigRequest.Timestamp = irmaSignature.Timestamp
if !irmaSignature.MatchesNonceAndContext(sigRequest) {
......@@ -328,7 +328,7 @@ func VerifySig(configuration *Configuration, irmaSignature *IrmaSignedMessage, s
}
// Verify a signature cryptographically, but do not check/compare with a signature request
func VerifySigWithoutRequest(configuration *Configuration, irmaSignature *IrmaSignedMessage) (ProofStatus, DisclosedCredentialList) {
func VerifySigWithoutRequest(configuration *Configuration, irmaSignature *SignedMessage) (ProofStatus, DisclosedCredentialList) {
// First, verify the timestamp, if any
if irmaSignature.Timestamp != nil {
if err := VerifyTimestamp(irmaSignature, irmaSignature.Message, configuration); err != nil {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment