darkrenaissance / darkfi

Anonymous. Uncensored. Sovereign.

Home Page:https://dark.fi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Zkas error in contract test

jaybutera opened this issue · comments

commented

When executing a test on the contract below in zkas I'm getting an error from constructing the ProvingKey (gist here).

I put in a debug print to see value in the function where the error happens (here).

running 1 test


STACKVARBase(AssignedCell { value: Value { inner: None }, cell: Cell { region_index: RegionIndex(1), row_offset: 0, column: Column { index: 0, column_type: Advice } }, _marker: PhantomData })

STACKVARBase(AssignedCell { value: Value { inner: None }, cell: Cell { region_index: RegionIndex(2), row_offset: 0, column: Column { index: 0, column_type: Advice } }, _marker: PhantomData })

STACKVARScalar(Value { inner: Some(0x28fa743ab00cca94b8c8d66be9cfeefed21f4ee8005d9e03091b1a515adb3fc3) })


thread 'test' panicked at 'not implemented', src/zk/vm_stack.rs:92:18

Seems like a StackVar::Scalar is trying to be converted into AssignedCell<pallas::Base, pallas::Base>. Is this a bug or a mistake in the code? Maybe my constants for the poseidon hash function are wrong I'm not sure what they mean.

constant "Mint" {
    EcFixedPointShort VALUE_COMMIT_VALUE,
    EcFixedPoint VALUE_COMMIT_RANDOM,
}

contract "Mint" {
    Base value,
    Base token_id,
    Scalar value_blind,
}


circuit "Mint" {
    C = poseidon_hash(value, token_id);
    constrain_instance(C);

    vG = ec_mul_short(value, VALUE_COMMIT_VALUE);
    rH = ec_mul(value_blind, VALUE_COMMIT_RANDOM);
    value_commit = ec_add(vG, rH);
    x = ec_get_x(value_commit);
    y = ec_get_y(value_commit);

    constrain_instance(x);
    constrain_instance(y);
}

@jaybutera Did you sort this out?