Create a Tamperproof Table
Creating a tamperproof table is very similar to a normal table, with a few restrictions
Proof of SQL℠ tamperproof queries enable many new use-cases at the intersection of Blockchain and AI, however, each SQL operation requires a new ZK circuit, so the SQL syntax has some limitations today. This page is intended to help guide developers on writing tamperproof queries, demonstrate what is available now, what's coming soon, and how to work around certain limitations.
Let's Get Started!
To be able to validate your script, we'd ask that you generate a new file called <span style={{ color: "blue" }}>Create_Tamperproof_Table.sh that you can commit to your branch of the SXT-Community/SXTAccreditation repo at the end of the activity.
Proof of SQL Syntax
Feature Availability
Tamperproof Table Requirements
Create Your Own Tamperproof Table
Let's take the example above and create our own tamperproof table, similar to the "Create Your Own Table" activity, although but with fewer columns, as Proof of SQL doesn't support all column types yet.
CREATE_SQL=$(cat << EOM
CREATE TABLE SXTTemp_TP.TestTP_<your UserID>_V1
( MyID BIGINT
, MyText VARCHAR
, PROOF_ORDER BIGINT
, primary key(MyID)
)
with "tamperproof=true, immutable=true, access_type=public_read, public_key=$RESOURCE_PUBLIC_KEY"
EOM
)
sxtcli sql \
--url=$API_URL \
--accessToken=$ACCESS_TOKEN \
--sqlText=$CREATE_SQL \
--biscuits=$ADMIN_BISCUIT
We can also insert new rows:
INSERT_SQL=$(cat << EOM
INSERT INTO SXTTemp_TP.TestTP_<your UserID>_V1
(MyID, MyText, PROOF_ORDER)
VALUES
( 1, 'Foo', 10)
, ( 2, 'Bar', 20)
, ( 3, 'Baz', 30)
, ( 4, 'Qux', 40)
, ( 5, 'Regoob', 50)
EOM
)
sxtcli sql \
--url=$API_URL \
--accessToken=$ACCESS_TOKEN \
--sqlText=$INSERT_SQL \
--biscuits=$ADMIN_BISCUIT
That said, UPDATES and DELETES are completely disallowed, and will throw errors if attempted.
DELETE_SQL=$(cat << EOM
DELETE FROM SXTTemp_TP.TestTP_<your UserID>_V1
WHERE MyID = 1
EOM
)
sxtcli sql \
--url=$API_URL \
--accessToken=$ACCESS_TOKEN \
--sqlText=$DELETE_SQL \
--biscuits=$ADMIN_BISCUIT
sql failed
[400] Bad Request
Details: Invalid operation (DELETE) on immutable table SXTTEMP_TP.TESTTP_
Create Table Best Practices
Get Credit:
You'll get credit for this activity if you:
- Create a new tamperproof table named:
SXTTemp_TP.TestTP_<your UserID>_V1
If your UserID has special characters that aren't accepted, simply replace them with underscores (). - Insert 5 rows into your new table
- Run a ZK-proven query against you new table
- Commit your work file to the SXT-Community/SXTAccreditation repo
{/ looking for some.table /}
Updated 5 months ago