Conversation
d322be2 to
77ba99a
Compare
ec1f128 to
bc1fcd1
Compare
f80c03a to
f761703
Compare
| deriving stock (Show, Generic) | ||
| deriving anyclass HasBlueprintDefinition | ||
|
|
||
| PlutusTx.Blueprint.TH.makeIsDataSchemaIndexed ''UserId [('UserId, 0)] |
There was a problem hiding this comment.
This is fine, but slightly less efficient. For newtype wrappers, we can essentially utilize newtype derivation for IsData and HasBlueprintDefinition as otherwise we are adding extra layer of Constr (from BuiltinData) on the value.
There was a problem hiding this comment.
ToData, FromData and UnsafeFromData worked fine with newtype deriving.
For some reason deriving newtype HasBlueprintDefinition did not work. The compiler issued an error: UserId type was not found in the list of types having schema definitions: [<a list of types>]. Only deriving anyclass HasBlueprintDefinition works.
| instance ZkFold.Scale Natural G1 where | ||
| scale n = ZkFold.scale (naturalToInteger n) | ||
|
|
||
| instance ZkFold.Scale F G1 where |
There was a problem hiding this comment.
Is this instance being used?
|
|
||
| correctLengths = length v == 16 && length aut == 16 | ||
|
|
||
| verified = and $ flip map (zip v aut) $ \(vi, auti) -> |
There was a problem hiding this comment.
It does make sense, and it will probably make the script more efficient. Thanks!
a73fdcb to
64cce5b
Compare
| newtype UserId = UserId { userId :: BuiltinByteString } | ||
| deriving stock (Show, Generic) | ||
| deriving newtype (ToData, FromData, UnsafeFromData) | ||
| deriving anyclass HasBlueprintDefinition |
There was a problem hiding this comment.
Please see #141. You may want to manually bring in those changes as that PR is apparently having many duplicate commits.
|
|
||
| slices = enumFromThenTo 0 2 30 | ||
|
|
||
| is = fmap (\s -> byteStringToInteger BigEndian $ sliceByteString s (s + 2) digest) slices |
There was a problem hiding this comment.
sliceByteString s 2 digest instead as I think second argument is length (not the end index).
|
|
||
| import ZkFold.Cardano.UPLC.Wallet.V0.Types (JWTParts (..), KeyId (..), OnChainWalletConfig (..)) | ||
|
|
||
| data PubKey = PubKey { pubE :: Integer, pubN :: Integer } |
There was a problem hiding this comment.
I notice that we are never using pubE -- if a different public exponent is ever registered in a beacon, we would be silently ignoring it. Perhaps we need to assert pubE == 65537 or use myExpMod vi pubE pubN.
|
|
||
| c = integerToByteString BigEndian 256 paddedHash | ||
|
|
||
| transcript = mconcat $ c : (integerToByteString BigEndian 256 <$> aut) |
There was a problem hiding this comment.
Since transcript contains no transaction-specific data, it seems that the same RewardingRedeemer can be copied from a previous valid transaction and submitted again to spend funds from the same wallet (replay attack).
If so, I think we can add TxOutRef to RewardingRedeemer, then transcript could be transcript = mconcat $ c : (serialiseData (toBuiltinData txOutRef)) : (integerToByteString BigEndian 256 <$> aut).
We would need to see how efficient it is, but first let's agree on the vulnerability.
There was a problem hiding this comment.
I agree. Previously, we tied a JWT to a temporary public key via ZK proof. Now, we need to add tx-specific data to the transcript.

No description provided.