#class CircuitString8 extends CircuitString

10 messages · Page 1 of 1 (latest)

leaden hollow
#

I would need to extends circuit string to use my own size, particularly, I want to use it to manage uuidv4 strings with out having to build 128length Circuit size. are there any plan to make CircuitString extendable in short term ?
I see it as a todo in o1Js code https://github.com/o1-labs/o1js/blob/de6d6b19665396150fda009668029eaf035b8e0b/src/lib/string.ts#L149

GitHub

TypeScript framework for zk-SNARKs and zkApps. Contribute to o1-labs/o1js development by creating an account on GitHub.

wide zodiac
#

Would o1js-pack work for you as an alternative string impl?

#

By the way, I think you could mess around with CircuitString locally. Like set the maxLength and array prop manually to use only 8 chars. Maybe you could just extend the class and set your own custom value?

#

In fact, I think the commented code in the string.ts file would work if you just uncomment it and put it in your own file.

// TODO
// class CircuitString8 extends CircuitString {
//   static maxLength = 8;
//   @arrayProp(Character, 8) values: Character[] = [];
// }
edgy yarrow
#

Hey @leaden hollow, you can of course extend all o1js composite types (anything but the Field type) as you like for your needs. However, unfortunately due to the 8 Field limitation on zkApps, the current implementation of CircuitString can have at most 8 characters (as each character is a Field). Nevertheless, you can use a packing solution like @wide zodiac describes to overcome this limitation (where you basically pack multiple characters into a single Field, as a Field is a veery big integer and you can store much more than 1 character inside). Please let me know if this helps!

leaden hollow
wide zodiac