Re: Prefix Conditions

Hey Stefan,

Yes, so my issue was I was validating with the original message instead of
doing it with an empty one.
It makes sense as the message is implicitly validated as it is part of the
fulfilment, right?

Thanks


On 29 November 2016 at 18:24, Stefan Thomas <stefan@ripple.com> wrote:

> Hey Javier,
>
> The code you posted looks correct to me and the example you posted
> validates for me:
>
> > cc.validateFulfillment('cf:1:EnsgInZhbHVlIjogMTIuOTkgfQAEYO
> wXK5OtXlY79JMscOEkUDTDVGfvLv1NZOv4GWg0Z-K_cn3fkbV_
> PzfYu9p1H7sVCGumRD4yupCF1LBINyBuSaB4tumYfz-bSB1PE006XF8rdW4dO5ZQ2KvsccW2SAz8Cg',
> 'cc:1:25:kh7u0e_LzueXf_YyKCU_6b9AdkrWyDLghpt7odcp4p4:115')
> true
>
> Can you share the code you're using to validate? Note that the prefix
> condition *adds* the prefix to the message for all subconditions below it,
> so you would want to validate against the empty string. In the JS library
> you can do that by just leaving out the message parameter.
>
> The reason it works this way is so that you can have different prefixes in
> different parts of the tree as well as prefixes that add on top of each
> other. In other words, it enables composability.
>
> > Buffer and Serialize are NOT financial or legal terms.
>
> It might be worth mentioning that crypto-conditions are just a standard
> way of doing composable cryptography (primarily complex multi-sig.) You
> could use them anywhere that you would use a signature scheme, for example
> as a way to authenticate HTTP requests. So they're a neutral technology and
> not specific to financial or legal use cases.
>
> That said, I do think that the interface is still very rough, so we should
> seriously review it at some point.
>
> On Tue, Nov 29, 2016 at 8:40 AM Andrew Bransford Brown <andrewbb@gmail.com>
> wrote:
>
>> The interface appears functional, however, needs serious review.
>>
>> Buffer and Serialize are NOT financial or legal terms.
>>
>> Andrew B. Brown
>> (512) 947-8282
>> http://KidsCourtyard.com
>>
>>
>> On Tue, Nov 29, 2016 at 11:20 AM, Javier Romero <elmurci@gmail.com>
>> wrote:
>>
>> Hi guys,
>>
>> I am trying to embed a message (*e.g. {"id": "the_id", "value": 0.98,
>> "description": "the description}*) in the condition through a Prefix
>> Condition.
>>
>> I create the condition this way:
>>
>>
>> const sender_fulfillment = new cc.Ed25519()
>> // Set public_key
>> sender_fulfillment.setPublicKey(new Buffer(pubKey, 'hex'))
>> // Prefix
>> const prefix = new cc.PrefixSha256()
>> prefix.setPrefix(message)
>> prefix.setSubfulfillment(sender_fulfillment)
>> // Condition
>> const condition = prefix.getConditionUri()
>>
>> And try to fulfil it like this:
>>
>> const receiver_fulfillment = new cc.Ed25519()
>> receiver_fulfillment.setPublicKey(pubKey)
>> const condition = receiver_fulfillment.getConditionUri()
>> receiver_fulfillment.sign(message, seed)
>> const prefix = new cc.PrefixSha256()
>> prefix.setPrefix(message)
>> prefix.setSubfulfillment(receiver_fulfillment)
>> const fulfillment = prefix.serializeUri()
>>
>>
>> These are the outputs:
>>
>>
>> *Condition:* cc:1:25:kh7u0e_LzueXf_YyKCU_6b9AdkrWyDLghpt7odcp4p4:115
>>
>>
>> *Fulfilment:* cf:1:EnsgInZhbHVlIjogMTIuOTkgfQAEYO
>> wXK5OtXlY79JMscOEkUDTDVGfvLv1NZOv4GWg0Z-K_cn3fkbV_
>> PzfYu9p1H7sVCGumRD4yupCF1LBINyBuSaB4tumYfz-bSB1PE006XF8rdW4dO5ZQ2KvsccW2S
>> Az8Cg
>>
>>
>> However, I am getting the below error when trying to validate it:
>>
>>
>> ValidationError: Invalid ed25519 signature
>>
>>
>>
>> gist: https://gist.github.com/elmurci/d3322fe3798335bac0aa6315349b4447
>>
>>
>> Any ideas?
>>
>>
>>

Received on Tuesday, 29 November 2016 20:36:16 UTC