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

The generator and primitive _nth_root #12

Closed
Federico2014 opened this issue Jul 28, 2022 · 2 comments
Closed

The generator and primitive _nth_root #12

Federico2014 opened this issue Jul 28, 2022 · 2 comments

Comments

@Federico2014
Copy link

Federico2014 commented Jul 28, 2022

I have a question about the generator and primitive _nth_root, it says the code also needs to supply the user with a generator for the entire multiplicative group, What is the entire multiplicative group, is it Fp*?
If the root is the generator of Fp*, how to derive the primitive_nth_root? why is the 407 omitted in the primitive_nth_root function? Can you tell me, thanks

  def generator( self ):
        assert(self.p == 1 + 407 * ( 1 << 119 )), "Do not know generator for other fields beyond 1+407*2^119"
        return FieldElement(85408008396924667383611388730472331217, self)
        
    def primitive_nth_root( self, n ):
        if self.p == 1 + 407 * ( 1 << 119 ):
            assert(n <= 1 << 119 and (n & (n-1)) == 0), "Field does not have nth root of unity where n > 2^119 or not power of two."
            root = FieldElement(85408008396924667383611388730472331217, self)
            order = 1 << 119
            while order != n:
                root = root^2
                order = order/2
            return root
        else:
            assert(False), "Unknown field, can't return root of unity."
@aszepieniec
Copy link
Owner

aszepieniec commented Jul 28, 2022

The entire multiplicative group is $\mathbb{F}_p^* = \mathbb{F}_p \backslash \lbrace 0 \rbrace$. A generator for it is a single element $g$ such that $\langle g \rangle = \lbrace g^i | i \in \mathbb{Z} \rbrace = \mathbb{F}_p^*$. The order of $g$ is always $p-1$ so in fact it is also correct to say $\langle g \rangle = \lbrace g^i | 0 \leq i &lt; p-1 \rbrace$ because the powers of $g$ outside this range fold onto powers of $g$ inside this range.

The function generator returns not a generator for the entire multiplicative group but only for the subgroup of order $2^{119}$.

@Federico2014
Copy link
Author

Ok, I see, thanks so much. It makes me quite confused when I read it the first time.

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

2 participants