Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mystique]tf.multiply(a,b), a,b的output scale均为2时,mystique uninit报错 #128

Open
yjsunn opened this issue Jan 16, 2024 · 0 comments

Comments

@yjsunn
Copy link

yjsunn commented Jan 16, 2024

测试代码:

import latticex.rosetta as rtt
import tensorflow as tf
rtt.activate("Mystique")
rtt.set_backend_loglevel(3)

#Define the input tensor
var1_data = tf.Variable(rtt.private_input(0, [[1]])) 
var2_data = tf.Variable(rtt.private_input(0, [[2]]))
var3_data = tf.Variable(rtt.private_input(0, [[3]]))
var4_data = tf.Variable(rtt.private_input(0, [[4]]))
#reshape
var_1 = tf.reshape(var1_data ,[1,1])
var_2 = tf.reshape(var2_data ,[1,1])
var_3 = tf.reshape(var3_data ,[1,1])
var_4 = tf.reshape(var4_data ,[1,1])

cipher_result_1 = tf.multiply(var_1,var_2)
cipher_result_2 = tf.multiply(cipher_result_1,var_3)
cipher_result_3 = tf.multiply(cipher_result_2,var_4)

cipher_result_4 = tf.multiply(var_1,var_2)
cipher_result_5 = tf.multiply(var_3,var_4)
cipher_result_6 = tf.multiply(cipher_result_4,cipher_result_5)#scale_2 * scale_2

cipher_result_7 = tf.multiply(cipher_result_3,cipher_result_6)
#Example usage
with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    print("result:",sess.run(rtt.SecureReveal(cipher_result_6)))
rtt.deactivate()

log报错:

|info|succeed in verifying zk!!
cut and choose fails

引发这个报错的原因是mystique在释放后端的时候报错了,请问怎么解决类似的报错呢?

除了这个之外我对mystique中mul和matmul的scale和truncate机制比较好奇。
1)请问为什么不直接将返回值都定义为truncate之后的值呢?

#define _OUTPUT_WITH_HIGH_SCALE true

(将output改为false后同样无法进行连续的mul或者matmul操作的验证)
2)MUL函数在处理highscale乘法的时候,code中有两种重载的inner_mul函数,请问两种函数都经过测试嘛?
3)MUL函数在处理highscale乘法的时候会调用函数inner_mul进行计算,最后返回值的output_scale默认为1。但是当在a_scale=2,rh=const时, output_scale的应该为2,最后需要进行truncate变为scale=1,为什么此处(
c_res[i] = FloatToInt62(ir_res, 0);
) float2int62的scale值为零呢?
4)如果想实现支持highscaleinput和truncate的matmul运算,有什么需要注意的地方吗?

十分感谢!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant