Feed on
Posts

## GF(5^2)

I got curious about the design of a puzzle a few weeks back using $$GF(5)$$, or more specifically, the extension field $$GF(5^2)$$. I was hoping that I could find pre-computed examples and while I found many examples of lectures discussing $$GF(5)$$, I didn’t find anything with extension fields of it. So I wrote a quick program to find primitive polynomials of degree 2 over $$GF(5)$$. For what I had in mind I needed 6 primitive polynomials which could be selected for construction of this field but sadly that was not the case. Since I went through the work to find all possible polynomials and I didn’t find anyone else that had done so, I decided I’d make a blog post of them in case it’s useful to someone else.

## The Field

While this may seem obvious, I’ll explicitly define what I used for $$GF(5)$$. I chose the integers $$[0, 4]$$ with $$+$$ and $$•$$ being addition and multiplication $$\mod 5$$. This makes $$0$$ the additive identity and $$1$$ the multiplicative identity. Basically, what you would expect one to use for $$GF(5)$$.

In my search for primitive polynomials, I only searched polynomials with a coefficient of $$1$$ for the $$x^2$$ component. This is because every polynomial with a different non-zero coefficient is just a scalar multiple of one with a coefficient of $$1$$.

## The Reducible Polynomials

Every story must have rising action and so next comes the failures of the polynomials which couldn’t make the cut. In the heat of the battle, these were the cannon fodder. The reducible polynomials of degree 2 over $$GF(5)$$.

• $$x^2 = x•x$$
• $$x^2+1 = (x+2)•(x+3)$$
• $$x^2+4 = (x+1)•(x+4)$$
• $$x^2+x = x(x+1)$$
• $$x^2+x+3 = (x+2)•(x+4)$$
• $$x^2+x+4 = (x+3)•(x+3)$$
• $$x^2+2x = x(x+2)$$
• $$x^2+2x+1 = (x+1)•(x+1)$$
• $$x^2+2x+2 = (x+3)•(x+4)$$
• $$x^2+3x = x(x+3)$$
• $$x^2+3x+1 = (x+4)•(x+4)$$
• $$x^2+3x+2 = (x+1)•(x+2)$$
• $$x^2+4x = x(x+4)$$
• $$x^2+4x+3 = (x+1)•(x+3)$$
• $$x^2+4x+4 = (x+2)•(x+2)$$

## The Non-primitive Polynomials

Then these polynomials managed to pass the first test only to fail in another. An n-degree primitive polynomial over $$GF(p)$$ must not divide $$x^m-1$$ for any $$m<p^n-1$$. In this case that means it must not divide $$x^m+4$$ for any $$m<24$$. So these polynomials fail that test; they got in a few licks before falling but ultimately didn’t make it.

• $$x^2+2$$ divides $$x^m+4$$ for $$m=8,16$$
• $$x^2+3$$ divides $$x^m+4$$ for $$m=8,16$$
• $$x^2+x+1$$ divides $$x^m+4$$ for $$m=3,6,9,12,15,18,21$$
• $$x^2+2x+4$$ divides $$x^{12}+4$$
• $$x^2+3x+4$$ divides $$x^{12}+4$$
• $$x^2+4x+1$$ divides $$x^m+4$$ for $$m=6,12,18$$

## The Primitive Polynomials

Now we finally reach the victors, the primitive polynomials. There are 4 of these and for each I’ll list the powers of $$\alpha$$ in vector notation starting with $$\alpha^0$$

• $$x^2+x+2$$ or $$x^2=4x+3$$
• 01, 10, 43, 42, 32, 44, 02, 20, 31, 34, 14, 33, 04, 40, 12, 13, 23, 11, 03, 30, 24, 21, 41, 22
• $$x^2+2x+3$$ or $$x^2=3x+2$$
• 01, 10, 32, 11, 42, 43, 03, 30, 41, 33, 21, 24, 04, 40, 23, 44, 13, 12, 02, 20, 14, 22, 34, 31
• $$x^2+3x+3$$ or $$x^2=2x+2$$
• 01, 10, 22, 14, 12, 42, 03, 30, 11, 32, 31, 21, 04, 40, 33, 41, 43, 13, 02, 20, 44, 23, 24, 34
• $$x^2+4x+2$$ or $$x^2=x+3$$
• 01, 10, 13, 43, 22, 41, 02, 20, 21, 31, 44, 32, 04, 40, 42, 12, 33, 14, 03, 30, 34, 24, 11, 23

And those are the primitive polynomials to construct $$GF(5^2)$$. Hope you had as much fun going through these results as I did finding them.

## The Appearance of Truth

I’ve had a scene from the movie “Man of the Year (2006)” rolling around in my mind for the past several weeks. For those who’ve not seen the movie, it about a comedian by the name of Tom Dobbs, played by Robin Williams, who decides to run for president as a third-party candidate. While he isn’t on the ballot in every state, he does win the states where he is on the ballot and achieves the majority of electoral votes to become the next President of the United States. Many of the voting machines used in the election were made by a company called Delacroy, and after the election one of its employees, Eleanor Green, played by Laura Linney, performs a unit test (or possibly systems test) on the devices. She discovers that when the devices are given a known set of input votes, the tally isn’t consistent with that input; it was miscounting. The reason for the error is related to the fact that the candidates have repeated letters in their names and the double b in Dobbs is the real reason why he won these states. (As a professional software developer, this is an idiotic rational unless the software is doing something really screwy with the candidates names. The names should be nothing more than an opaque string but I digress) So she first takes this to her boss, Stewart, played by Jeff Goldblum, and he decides try to supress this information presumably for he sake of the company’s reputation. Anyway, she managed to convince Dobbs of all this, he withdraws from the race, and as a result Time Magazine names him Man of the Year.

What always stuck in my mind is what Stewart said to Eleanor in this exchange. This is mostly quoted on IMDB but not quite correctly, at least in comparison to what’s on the DVD. I presume the quote there was taken from the script and the actors changed it slightly in filming. Here is the quote on the DVD:

Here. Here it is in the sense of light of day. The people are voting, there is an election, the democratic process has worked. The only sour note: The people won’t end up with the person that they voted for to be President of the United States but, we can celebrate the process, the democracy which we hold so dear, will have worked, efficiently. Effectively, everybody’s ultimately gonna be satisfied unless somebody discloses, indiscriminately, willy-nilly, in which case it will appear that democracy is in the s**t-house and tomorrow evening Delacroy will be non-existent. Now was that your motive?

No.

America votes, a leader is chosen, but one thing could disturb the beatific vision.

I just want to be truthful.

Perception of legitimacy is more important than legitimacy itself. That’s the greater truth. Don’t f**k with our democracy. Don’t undermine our way of life. You want to know what is in the heart and soul of every American? They believe their vote counts. Now you wanna tell them that’s not true?

This part always stuck in my mind because Stewart was so flippant about the election that he would rather the election results not correspond to the actual votes cast (not be true) and perpetrate a deception rather than even entertain the notion that the results may not be true. When I first saw this, I couldn’t believe that there could be anyone who would hold such a view about something so critical to the country as an election but then I was just one of the sheep that Stewart didn’t want to be informed of the truth.

Today I’m reminded of this scene because many people are taking the same attitude as Stewart in relation to election audits. Suppress, delay, destroy, lie, and whatever it takes to stop the audit in any form. People watching are left with the questions: why try to stop an audit? What do they have to hide? The problem is, that’s the wrong question.

The correct question is: why are election audits so rare in the first place? Not only do we need the ones proposed, but they need to be common, random, and at all levels of the election. They need to occur in cases where you expect to find nothing awry. If you want to prevent fraud, you present a system that causes fraud to be caught. If you want the truth, you check to make sure the results are actually true.

There has long been a level of fraud in the elections and everyone knows it. Jokes have abound for years about certain areas of the country where the dead still vote. Humor like this only works because it has a basis in truth. Additionally I have examined election results decades ago where counties had 100% turnout and 100% voted for a particular presidential candidate. An appeal to the best explanation wouldn’t leave a person to conclude that it was completely legitimate. Regular audits were needed back then.

Then we get to the 2020 election. There have been so many irregularities that we are past the point where the American people can have trust in the integrity of elections. Nothing short of auditing every single contested election could even begin to restore this faith. I doubt we are going to see this and the result is the fraud will continue.

So the question we must ask ourselves is: are we to actually have elections or the appearance of elections?

## A Litany of Netflix Screw-ups

For those unaware, Netflix still does their DVD by mail service. Both my dad and I have subscribed to this in the past. Occasionally when I would visit my parents (200 miles away), I would change the shipping address on my account to his place so my DVDs would be sent there and change it back when I would leave (relevant later in this post). We both hit the point where every movie in our queue had a wait on it so we both cancelled the service. We’ve done this twice before. Now, several months later, we both decided that we should renew the service because enough movies have been released in the mean time that we should go several months until this occurs again.

### Starting the DVD Plan Online

We both went to our respective accounts and tried to start the DVD Plan online. We both got to the third page of this setup which asks for payment details and that’s where we both encountered issues. In my case the credit card had expired since I last used the service so I needed to update the information. In my dad’s case it asked for the CCV number for the card already on file. We each were met with an error message asking to call in to their support center. Being a Sunday, we had to wait until the next day. My dad tried a few other credit card numbers and they each yielded the same results. In both of our cases looking at the browsers’ dev tools we could see the request the browser made was met with a 500 HTTP reply (here it is explained by a cat) which means the server screwed up.

### Calling in

We both called in on Monday to phone number provided to us in the error message on the web page. When calling into Netflix, it’s best if you get the service code so they can more easily lookup your account. I went to my account page and obtained this code and provided it when calling in. The problem is this service code is for the streaming side of Netflix and doesn’t work for the DVD side. It turns out a user CANNOT get a service code anywhere for the DVD side without an active DVD Plan. So I had to give my email address for the account and then the service person hung up on me. No explanation or comment, just *click*.

So I called in again, and talked to Wendy (not the same person). I gave my email address on the account, explained my circumstances, and stated that I wanted to start up my DVD plan again. She saw on my account the expired credit card, asked for the details on the new card, entered it in, and then told me that their system rejected it. She asked about another card or if there was something wrong with the card. I assured here there was absolutely nothing wrong with this card, mentioned my dad’s experiences, mentioned the 500 error, and told her the natural conclusion is the problem is entirely on their side. Then she tells me that the credit card on my account just updated. She doesn’t know what caused it to update but it did.

While I was still on the phone with her, I tried to activate my DVD plan online and on that third page it didn’t prompt me for any information but just asked if the credit card on file (now the updated one) was the one to be used. I continued and it activated the DVD Plan. Wendy suggested that the problem may be that they cannot update payment details on an expired account even if the account is currently in the process of being resumed.

My dad called in and his experiences were far worse than mine. I explained to him what I did and the results I got which he relayed to the ones he talked to. First he encountered problems with them looking up his account. In spite of giving them the correct email address, the support person insisted that there is another email address. Additionally he was asked a series of odd questions which had no bearing on the situation. Regardless, in talking to them over the course of days, he was told that my action of changing the address on my account to his address when I would visit is the cause of the problem. Additionally that the same problem would result if two people had separate accounts who happened to be roommates.

When my dad told me this, I called in and asked if that was the case and what I need to do to prevent this problem in the future. I was assured that this was not a problem in the least. Despite being asked several times, the person I was talking to absolutely refused to tell me that the person my dad was talking to was wrong despite directly contradicting his statements. So one of them is providing customers with misinformation.

In subsequent calls, my dad was informed that his credit cards (he had tried several) were not being declined but in fact were being rejected by their internal system before going to the payment processor. He was told that he could try a gift card but there didn’t seem to be a way to start the DVD Plan without providing a credit card even if the payment was going to be via gift cards. They did admit that if the gift card didn’t work he would be out the cost of the gift card and could not get that money back. He was also told that there could be an issue with their internal systems with too many attempts being made on it and he should wait 24 hours before trying again.

He waited two days and in the mean time he received two emails from Netflix one of which was a marketing email suggesting he sign up for their DVD Plan. So, after waiting, he tried the website again with no change in results, and called in again and again no change in results. Fighting with their support people who were entirely incapable of solving the problem and additionally incapable of talking to anyone who could, he gave up on them.

So, he instead tried to reactivate the streaming side. It’s no secret that Netflix cares far less for the DVD side of their service so maybe the problem is long since solved on the streaming side or at least maybe their support are given a better ability to fix it. Using the website first, he was successful in confirming the payment details for the card they already had on file and starting the streaming plan. He then tried to add a DVD plan to this account and was successful there as well.

### Summary of Netflix’s Problems

In this process, we uncovered several problems Netflix has in their DVD by mail service. Not only have they significantly cut back on their warehouse locations and thus decreased the quality of their service without decreasing the price, but they also seem to not want people to actually sign up for their service. I have to wonder how much of the decline in their number of customers is due to others running into the same problems but not being as persistant as we were. Netflix, when people want to give you money, you shouldn’t make it difficult for them to do so. So, a summary of the problems we noticed is:

• Internal Server Errors on the server are apparently not monitored or at least not fixed quickly or this problem would have been resolved on its own when we attempted again later.
• A user cannot get a service code to the DVD side without having an active DVD account. This calls into question why they are different in the first place.
• Misinformation provided by call support staff.
• Cancelled accounts cannot be updated as necessary to resume the account (this may be misinformation but it is the best explanation that fits the evidence)
• Netflix DVD has a problem if an account is being resumed with an address previously used by a different account (this may be misinformation). If this is true, sounds like this can be exploited in a Denial of Service attack.
• Suggesting users buy a gift card when it doesn’t provide a solution to the problem (cannot bypass whatever is rejecting the credit card details we were providing)

## Plex Media Player Appliance Using Ubuntu

Running the embedded version of Plex Media Player requires several compromises when a better experience can be obtained by using a full OS install. So I went through the steps to install PMP on an Ubuntu installation. Not only do I have a powerful playback appliance for Plex but I also have a computer where I can use a browser or any other application where I would want the computer displayed on a TV.

I’m going to assume that the reader is familiar with Linux install, setup, and use so I’m not going into extensive detail in these steps.

• If you are coming from a previous embedded installation, you should grab autostart.sh, plexmediaplayer.conf, mpv.conf, and inputmaps
• It is easiest if you turn on SMB sharing and access the shares. The autostart.sh is in the Configfiles share and the others are in the PMPConfig share
• Install Ubuntu
• It is much more convenient to set it to auto-login when you create the user so you don’t have to type in the password when you reboot the device
• Reboot after install completes (it should ask you to do this)
• Open System Preferences (power icon in upper right -> tools looking icon in lower left of menu)
• In Power change Blank screen to Never to disable the auto-lock
• Change the desktop background (the default background is such high saturation that it produces a noticeable afterimage on your retina after looking away)
• In Notifications turn off the two types of notifications
• In Privacy edit the problem reporting and turn it off. It should then say Never when complete. This disables the dialog displaying over the video.
• Disable the update notification dialog (so it doesn’t show up in the middle of your playback)
• In terminal, execute cd ~/.config/autostart
• cp /etc/xdg/autostart/update-notifier.desktop .
• Edit that file update-notifier.desktop and add a line Hidden=true to the end
• Run software update (likely need another reboot)
• This is an opportune point to configure Bluetooth devices and WiFi should you use them
• Mostly follow these instructions: https://github.com/plexinc/plex-media-player#building-on-linux
• In the first, with the list of things to install, add python to the list
• You may use the OS provided Qt or install it from the installer
• When you download the Qt installer, you must make it executable before you can open it. Ctrl-I will show a dialog and in the Permissions, check the box to make it executable
• When installing QT, select version 5.12.3 (you can unselect the android versions)
• When doing the building mpv steps, execute ./use-mpv-release && ./use-ffmpeg-release before the rebuild step to use the a release version over development
• When building PMP itself, the -DQTROOT will be -DQTROOT=/home/username/Qt/5.12.3/gcc_64/ (substitute in your username)
• If your are coming from a previous installation, create the dir ~/.local/share/plexmediaplayer and put the plex config files in there
• In the PMP checkout, copy the resources/desktop/plexmediaplayer.desktop to the desktop
• Change the exec line to read Exec=env QT_XCB_GL_INTEGRATION=xcb_egl plexmediaplayer
• Execute this shortcut because it must be run once to become trusted. You’ll need to make it executable first just like above
• Create a bin directory in your home dir and in it create the file setupAndLaunchPMP.sh with the contents:
#!/bin/sh

# Put any previous setup commands you had in here such as came from your old autostart.sh file

sleep 2

QT_XCB_GL_INTEGRATION=xcb_egl plexmediaplayer
• Make sure the file is executable
• Go into the startup applications
• Make a login item to execute the above script on login

## Updating

• Updating Ubuntu itself can be done by launching the Software Updater application
• PMP can be updated by:
• Opening the terminal and change directory into the PMP source you grab earlier
• git pull
• cd build
• make -j4
• sudo make install
• Then restart PMP and you are updated

## Switch to ALSA Audio

Ubuntu comes with PulseAudio configured but PulseAudio doesn’t support matching the channel count of the output with the source audio. So if you configure it to output 7.1 and you play content that’s in stereo, it will up-convert your stereo content to 7.1 and, to my ears, definitively do it incorrectly. I’d much rather have my AVR get stereo and it do the pro-logic decode or whatever processing I have configured on it.

• Disable pulse audio (Ubuntu 18.04)
• cp /etc/pulse/client.conf ~/.config/pulse
• Edit ~/.config/pulse/client.conf
• Change the line ; autospawn = yes to autospawn = no
• Change the line ; daemon-binary = /usr/bin/pulseaudio to daemon-binary = /bin/true
• Disable pulse audio (Ubuntu 20.04 since the above no longer works)
• systemctl --user mask pulseaudio.socket
• systemctl --user mask pulseaudio.service
• In PMP’s settings:
• In Audio, disable all the codecs for audio passthrough
• In Audio, set the output device. Mine was HDA Intel PCH, HDMI 0/HDMI Audio Output (the first HDMI one)
• Set Audio -> Channels to Auto Select Channels
• In Video -> Sync Mode, set this to Display (resample audio)
• Reboot to ensure all the steps are working
• Run a ps ax | grep pulse and ensure that the only line you get (if any) is the grep command

## Using Passthrough

I attempted to use passthrough repeatedly on my NUC8 but no matter what I tried it would not passthrough any HD-audio codecs (TrueHD/DTS-HD) but it had no issue with AC3, EAC3, and DTS. My NUC4 has no issues with any of the codecs so, including the HD-audio ones, go figure. This issue appears to be exclusively an issue with the receiver not being HDMI 2.0. Upon upgrading to an HDMI 2.0 receiver, the HD-audio codec passthrough worked on the NUC8. Perhaps an Intel bug to do the passthrough in a means that an HDMI 1.4 device didn’t understand.

• First follow above settings to use ALSA
• In PMP’s settings:
• In Audio, ensure you have the passthrough codecs selected in audio
• In Video -> Sync Mode, set this to Audio
• I have tried fiddling with the video-sync=display-vdrop setting here and it appears to work better than audio but this requires modification to PMP’s source code.

## Customization

### mpv.conf

Modifications to the mpv.conf file allow a great amount of control to how the playback performs. Most notably if the hardware is capable enough, it can greatly enhance the quality of video scaling and playback in general. There are a great many posts on this topic (such as this one) but at the moment I am using the following:

video-output-levels=limited

demuxer-mkv-subtitle-preroll

profile=gpu-hq
deband=yes

# interpolation=yes
# tscale=oversample

scale=ewa_lanczossharp

audio-stream-silence=yes

#### Explanations

• video-output-levels=limited: I have my TV configured to accept the limited color space. Similarly I’ve configured the graphics card to output full. See this forum post for more details. I have a xrandr --output DP-1 --set "Broadcast RGB" "Full" in my setupAndLaunchPMP.sh file
• demuxer-mkv-subtitle-preroll Appears to show subtitles immediately after a seek instead of waiting for the next set of subtitles before display.
• profile=gpu-hq An easy profile to gain a lot of playback enhancements.
• deband=yes Reduce any visible banding artifacts
• interpolation=yes Provides from interpolation for cases where the display framerate cannot be matched to the source. I have since disabled this because it can rarely cause frames to be displayed out of order. Since I match framerates almost every time, I rarely need any frame interpolation and the disadvantage outweighs the advantage for me.
• tscale=oversample Configuration for the interpolation to use a simple mechanism. This does not do motion enhancement or the so-called “soap opera effect.” I have also disabled this; see above.
• scale=ewa_lanczossharp Overrides the scaler used in the gpu-hq profile with one that yields better quality
• audio-stream-silence=yes Plays silence while the video is paused. This appears to resolve a small audio drop I experience sometimes after I resume from pause

### plexmediaplayer.conf

Almost all of these are accessible in the UI but a few are not. Among the latter, ones I have changed are:

• Video
• audio_delay.24hz, audio_delay.25hz, audio_delay.50hz, audio_delay.normal to set audio delay at various refresh rates to ensure A/V sync in playback.
• refreshrate.avoid_25hz_30hz I set the to false because the 29.97Hz refresh rate appears to yield the best playback experience for a DVD remux.
• refreshrate.delay I’ve set this because my TV takes a few second between a refresh rate change and display of the video

### Inputmaps

You can copy the example input map to the inputmaps dir and modify it to change the actions taken on a keypress. This is going to be very user specific but essentially I’ve set keymaps to do:

• cycle_subtitles
• cycle_audio
• host:cycle_setting video.aspect

The actions these take should be fairly self explanatory.

## Conclusion

That’s it. I feel this technique of running a full OS instead of the embedded LibreELEC OS provides a better experience to the end user in the long run. It’s significantly easier to setup BlueTooth devices in Ubuntu than it is in LibreELEC as well as any other hardware setup I might wast to do.

Hopefully you have find this guide useful and enjoy your playback setup.

## Edits

• 2019-12-02: Added disabling the problem reporting dialog
• 2020-01-21: Disabled interpolation due to frame ordering issue
• 2020-10-28: Added info on how to disable pulseaudio in Ubuntu 20.04
• 2020-11-16: Added QT_XCB_GL_INTEGRATION=xcb_egl environment variable since it allows for better hardware decoding

## Using ACLs to Solve Permissions Issues

One of the more annoying issues that can impact novices on Linux systems is handling permissions across multiple users. One of the contexts where I see this the most is on the Plex forums where users have to deal with allowing the Plex Media Server to see their media when it runs as a different user. Years ago I solved this problem on my system with using ACLs and I’ve never had to deal with the permissions on my media since.

#### Enable ACLs

The common filesystems on Linux systems tend to support ACLs but they are often disabled. For many they can be turned on by adding acl to the mount options in the /etc/fstab.  Ubuntu’s documentation has better instructions than I can give here.  For those using ZFS, you can run zfs set acltype=posixacl filesystemName and it’ll enable the ACLs for you immediately (no need to re-mount the filesystem).

#### ACL Setup

The easiest solution is to setup the ACLs on the root directory and then use a command that copies the ACLs down the directory tree.  So first enter the root media directory and execute:

setfacl -m o:- .
setfacl -m d:o:- .
setfacl -m m:- .
setfacl -m d:m:- .
setfacl -m u:$USER:rwX . setfacl -m d:u:$USER:rwX .
setfacl -m u:plex:rX .
setfacl -m d:u:plex:rX .

(fill in $USER with your desired username above) The above does the following (each description corresponds to a pair of lines above): 1. Remove the permissions for other users and their default permissions 2. Clear out the permissions mask 3. Add the your user with full permissions 4. Add the plex user with read and execute permissions (execute needed to enter directories). The default entries define the ACL entries that a new file or directory receives. From the above, your user will automatically get full permissions to the file and the plex user will get read access. Once the permissions for the root directory are as desired, you can copy them to all subdirectories and files (shamelessly stolen from this SO post): find . -mindepth 1 -type d| xargs -n 50 setfacl -b --set-file=<(getfacl . | sed -e 's/x$/X/')
find . -mindepth 1 -type f| xargs -n 50 setfacl -b --set-file=<(getfacl . | grep -v '^default:' | sed -e 's/x\$/X/')

The above takes all the ACL entries from the current directory, translates the lower-case x at the end to a capital X (this means only apply the execute permission to directories and executable files), and then use this result to overwrite the ACL entries on every sub-directory.  The second command is similar but it applies to files instead and removes all default entries (because files cannot have default entries as they only apply to directories).

#### The Result

The permissions for my media files are exactly as I desire regardless of how they are created.  I don’t have to worry about umasks, sticky bits on the group, group membership, or too permissive files.  I can have a umask of 077 where files are created without allowing any permissions to any other user, and with the ACL setup, the plex user will still be able to read the media files.  If I rsync the files over preserving permissions, the group name and permissions don’t matter; the plex user will still be able to read the media files.  Basically, everything I do, apart from modifying ACL entries, the plex user will still be able to read the media files.  This truly is a set it and forget it kind of setup.

Older Posts »