Prophet Functions
Ola supports the prophet
function, which utilizes prophet features to make previously difficult-to-prove but easy-to-verify computation processes now easily provable and verifiable, improving ZK circuit proof efficiency.
The following demonstrates the usage of the u32_sqrt
prophet function supported by ola.
fn sqrt_test(u32 n) -> (u32) {
u32 b = u32_sqrt(n);
return b;
}
We can also use the Ola language to implement a simplified version of the sqrt function.
// native approach
fn sqrt_test(u32 a) -> (u32) {
u32 result = 0;
if (a > 3) {
result = a;
u32 x = a / 2 + 1;
// assume the maximum iteration is 100
for (u32 i = 0; i < 100; i++) {
if (x >= result) break;
result = x;
x = (a / x + x) / 2;
}
} else if (a != 0) {
result = 1;
}
return result;
}
The efficiency comparison of circuit proof generated by using the Ola Prophet method and directly written in Ola language for sqrt is as follows:
Last updated