Giter Club home page Giter Club logo

Comments (10)

rivertalk avatar rivertalk commented on May 20, 2024

Hi @DuanYuFi , thanks for the question

Why the first item in the templates is the class itself? Is that a stipulation?

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.

Is RingTy means this data is in ring?

Yes, you can think RingTy as SPU VM's unsigned integer, but with more clear semantic.

Is Secret means this data is secret instead of public?

Yes, you will see something like x.eltype().ias<Secret>, which test if the value is a secret value.

s AShare emphasizes that this is an Arithmetic data? In other words, the point of it is Arithmetic instead of Share?

It means a Arithmetic shared data, an AShare is a Secret Share, which is, of course, a Secret.

Is 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), and TypeImpl only defines attribute such as RingTy, Secret, etc. but don't store x0, x1.

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

from spu.

DuanYuFi avatar DuanYuFi commented on May 20, 2024

Thanks for your detailed answer, it solves all my questions. Thank you!

from spu.

DuanYuFi avatar DuanYuFi commented on May 20, 2024

Hi, if I want to build a field type, should I still use RingTy? I didn't find something like FieldTy.
By the way, happy Lunar Newyear to everyone :)

from spu.

DuanYuFi avatar DuanYuFi commented on May 20, 2024

Seems that according to our previous conversation:

Yes, you can think RingTy as SPU VM's unsigned integer, but with more clear semantic.

RingTy means unsigned integer, of course it could represent field element. And RingTy has an attribute Ring2k, which has some comments

// This trait means the data is maintained in ring 2^k, it DOES NOT mean that
// data storage is k-bits.
// For example, some protocol works in Zq, but the data it manipulates on is
// [0, 2^k).

Thanks LOL, if anything incorrect, please tell me.

from spu.

rivertalk avatar rivertalk commented on May 20, 2024

Hi, if I want to build a field type, should I still use RingTy? I didn't find something like FieldTy. By the way, happy Lunar Newyear to everyone :)

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)

from spu.

DuanYuFi avatar DuanYuFi commented on May 20, 2024

OK, thanks for your detailed reply. You are right, I'll spend some time to comprehend。

from spu.

DuanYuFi avatar DuanYuFi commented on May 20, 2024

What's the difference between TypeObject, FieldType and ring2k_t (from Ring2kTrait)?

from spu.

DuanYuFi avatar DuanYuFi commented on May 20, 2024

It seems that FieldType is included in TypeObject, and ring2k_t is some struct related to FieldType?

from spu.

rivertalk avatar rivertalk commented on May 20, 2024

TypeObject is just a general object that represent a type, you can derive from it to represent a concrete type. i.e.

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.

from spu.

DuanYuFi avatar DuanYuFi commented on May 20, 2024

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.

from spu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.