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
#class CircuitString8 extends CircuitString
10 messages · Page 1 of 1 (latest)
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[] = [];
// }
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!
thank you ! your example is indeed very useful because I also need it for ipfs hash ! I will explore and see if / how to implement it in my code
very helpful , thanks !
Feel free to friend/dm me. Some other people have told me it was easy to incorporate into their apps, but Id love to know if you have any trouble.