-
Notifications
You must be signed in to change notification settings - Fork 94
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
Question about the Type system #62
Comments
Hi @DuanYuFi , thanks for the question
Yes, it's a stipulation, the pattern is from https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern, it's widely used in a number of C++ projects, like LLVM/Eigen/xtensor.
Yes, you can think RingTy as SPU VM's unsigned integer, but with more clear semantic.
Yes, you will see something like
It means a
Yes, type is type, value is value. Type just describes the runtime type information of values, its does not hold content of values. Jin, |
Thanks for your detailed answer, it solves all my questions. Thank you! |
Hi, if I want to build a field type, should I still use RingTy? I didn't find something like FieldTy. |
Seems that according to our previous conversation:
RingTy means unsigned integer, of course it could represent field element. And RingTy has an attribute
Thanks LOL, if anything incorrect, please tell me. |
Let me guess, you are trying to add a new protocol which works on Zq, but the upper layer (Hal layer) assumes all operations works on Z2k(Ring2k). If am correct, you can simply expose the type as Z2k(Ring2k), because the upper system use this trait to interact with protocol layer. But inside your protocol, maintain Zq storage and related operations. In the future, we may support Zq from the HAL layer, which means, HAL acts differently according to the working field. At that time, we can 'lift' Zq to //spu/core/type.h (from your protocol's local definition) |
OK, thanks for your detailed reply. You are right, I'll spend some time to comprehend。 |
What's the difference between |
It seems that |
class MyPrototocolType : public TypeObject {}; But the system sometime want to know how your derived type behave like, i.e. does like behave like a Ring2k, or a boolean share? So we should add these interface to it. class Ring2k {
FieldType field(); // return the concrete field of this ring.
};
// also inherit from Ring2k
class MyPrototocolType : public TypeObject, public Ring2k; And finally, we use CRTP and concept model idiom to inject some other information to the classes. class MyProtocolType : public TypeImpl<MyProtocolType, Ring2k, ...> {} ring2k_t is totally a different thing, it's use to dispatch to static type according to dynamic type. i.e // if you define
enum CppType {
Int32,
Int64,
};
if (ty == Int32) {
using ring2k_t = int32_t; // inject static type information here.
fn(...); // call your lambda function, and the `ring2k_t` is injected.
} else if (ty == Int64) {
...
} Have a nice day. |
That's a detailed description. Thank you. I learned so much about computer systems, principles of compiles, etc. in this issue than what I've done all my life. I hope I can get on it well as soon as I can. |
Hi, I am reading the code about the definition of secret share, and in spu/mpc/aby3/type.h: 22, AShrTy inherits from
TypeImpl<AShrTy, RingTy, Secret, AShare>
. I followed intoTypeImpl
and here are my questions:RingTy
means this data is in ring?Secret
means this data is secret instead of public?AShare
emphasizes that this is an Arithmetic data? In other words, the point of it is Arithmetic instead of Share?TypeImpl
just defined the attribute of the share, and it doesn't store any real data? For example, there's a replicated secret share (x0, x1), andTypeImpl
only defines attribute such as RingTy, Secret, etc. but don't store x0, x1.Thanks for reply!
The text was updated successfully, but these errors were encountered: